Skip to content

Explain refused Circles ownership transfers - #84

Merged
oleksandr-nc merged 2 commits into
mainfrom
fix/circles-owner-transfer-error
Sep 26, 2026
Merged

oleksandr-nc merged 2 commits into
mainfrom
fix/circles-owner-transfer-error

Conversation

@oleksandr-nc

@oleksandr-nc oleksandr-nc commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Making someone the owner of a circle fails on many servers with a raw database error. When Circles transfers ownership, it locks the member rows with a SELECT ... FOR UPDATE over a left join. SQLite cannot build that query ("Operation 'FOR UPDATE' is not supported by platform"). PostgreSQL refuses it ("FOR UPDATE cannot be applied to the nullable side of an outer join"). Circles fixed this in nextcloud/circles#2916 and #2917 (stable34 and stable35, merged 2026-09-18). Nextcloud 35.0.1 has the fix. 34.0.4, 35.0.0 and the current 32 and 33 images do not, and MySQL was never affected. Moving CI to PostgreSQL (#82) exposed it: the owner-transfer test still skipped on the nextcloud:34 image, with a skip message that blamed SQLite.

update_circle_member_level now explains such a refusal:

  • The server's Circles cannot transfer ownership, and updating Nextcloud fixes it.
  • Nothing was changed. The lock is the transaction's first statement, so the rollback leaves both levels as they were. No other part of the level change runs.
  • Other level changes still work. The owner transfer is the only place Circles takes this lock.

The match needs "FOR UPDATE" together with "not supported" or "outer join". Other errors, and the same error for any other level, pass through unchanged. The docstring mentions it in one sentence.

Tested on the official Nextcloud 34 image with PostgreSQL 17, where the transfer is refused. The integration test now checks that the owner and the member kept their levels before it skips, and the skip names the Circles fix. The Circles tests pass on the local MySQL servers for Nextcloud 34 and 35. Unit tests cover the PostgreSQL and SQLite refusals, an unrelated FOR UPDATE error and non-owner levels.

Summary by CodeRabbit

  • Bug Fixes
    • When an ownership transfer is refused by an older Circles server because of a database limitation, the error now explains that ownership was not changed.
    • Other errors continue to be reported unchanged, and failed transfers do not alter member levels.

Signed-off-by: Oleksandr Piskun <oleksandr2088@icloud.com>
Signed-off-by: Oleksandr Piskun <oleksandr2088@icloud.com>
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: fd43be72-ab97-4f8a-927e-62018800b3ae

📥 Commits

Reviewing files that changed from the base of the PR and between 02e744a and 5da51cb.

📒 Files selected for processing (5)
  • PROGRESS.md
  • scripts/sync_progress.py
  • src/nc_mcp_server/tools/circles.py
  • tests/integration/test_circles.py
  • tests/test_circles.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

update_circle_member_level now reports specific row-lock errors during owner transfers as a descriptive ownership-transfer error. Unit and integration tests cover the handling, and Circles test-count tracking includes both test modules.

Changes

Circle ownership transfer

Layer / File(s) Summary
Handle owner-transfer refusals
src/nc_mcp_server/tools/circles.py, tests/test_circles.py
The tool detects specified row-lock errors when the requested level is owner and raises a descriptive ValueError. Other errors pass through unchanged. Unit tests cover both cases.
Validate integration behavior and test counts
tests/integration/test_circles.py, scripts/sync_progress.py, PROGRESS.md
The integration test checks that a refused transfer leaves both member levels unchanged. Test collection includes test_circles.py, and the recorded Circles and overall test counts increase by six.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5da51

The ownership-transfer error handling has no identified issue that needs correction before merge.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 5da51

The change explains a known server refusal without adding a write path or relaxing permissions. The no-change message depends on the server’s rollback behavior, which the available test checks for the two ownership levels but not for all server state.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed response can affect callers already permitted to request a Circle member-level update. The request’s Circle, member, permission gate, and Nextcloud endpoint are unchanged, so the evidence does not show expanded write authority.

Trust Boundaries and Controls

  • observed — The new classification consumes error text supplied by the Nextcloud response. Its effect is limited to the error reported to the caller; it does not authorize a request or produce a successful update response.

Resilience and Maintainability Implications

  • observed — The refusal test verifies that both relevant role levels remain unchanged before skipping on an older server. That check supports, but does not fully prove, the broader no-change message.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: explaining refused Circles ownership transfers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@oleksandr-nc

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.41%. Comparing base (02e744a) to head (5da51cb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #84   +/-   ##
=======================================
  Coverage   97.40%   97.41%           
=======================================
  Files          33       33           
  Lines        4819     4828    +9     
=======================================
+ Hits         4694     4703    +9     
  Misses        125      125           
Flag Coverage Δ
integration 94.84% <90.00%> (-0.02%) ⬇️
nc34 94.51% <90.00%> (-0.02%) ⬇️
nc35 94.51% <40.00%> (-0.12%) ⬇️
py3.12 47.61% <100.00%> (+1.40%) ⬆️
py3.13 47.61% <100.00%> (+1.40%) ⬆️
py3.14 47.61% <100.00%> (+1.40%) ⬆️
session-cache 18.76% <20.00%> (+<0.01%) ⬆️
unit 47.61% <100.00%> (+1.40%) ⬆️
user-permissions 41.34% <20.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oleksandr-nc
oleksandr-nc merged commit 60f9234 into main Sep 26, 2026
12 checks passed
@oleksandr-nc
oleksandr-nc deleted the fix/circles-owner-transfer-error branch September 26, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant