Skip to content

fix: [stable-8.0][OCISDEV-1714] keep the role of a user when settings cannot read it - #13526

Open
2403905 wants to merge 1 commit into
stable-8.0from
fix/8.0/OCISDEV-1714
Open

2403905 wants to merge 1 commit into
stable-8.0from
fix/8.0/OCISDEV-1714

Conversation

@2403905

@2403905 2403905 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

The settings service could remove the role of a user without an error:

  1. The read of a role assignment fails.
  2. ListRoleAssignments returns an empty role list.
  3. The proxy assigns the default role "User" (services/proxy/pkg/userroles/defaultrole.go, UpdateUserRoleAssignment).
  4. WriteRoleAssignment deletes the old assignments first, so an Admin becomes a User.

The main cause is in reva: each connection error of a metadata download became NotFound. owncloud/reva#820 fixes it. This PR closes the other paths to the same result in the settings service.

Changes

  • Fail closed in AssignRoleToUser (services/settings/pkg/service/v0/service.go). The self-assign check was err == nil && len(r) > 0. A read error let the write through. Now a read error returns an error, and the service does not write.
  • Drop a stale folder listing (services/settings/pkg/store/metadata/cache.go). Each settings pod has its own memory cache by default. After a role change on pod A, the cached listing on pod B can name an assignment file that is gone. When the files cache entry expires first, the download gives a real NotFound, and the list is empty. CachedMDC.SimpleDownload now drops the cached listing of the folder on NotFound.
  • Read the folder again (services/settings/pkg/store/metadata/assignments.go). ListRoleAssignments reads the account folder one more time after a stale listing.
  • Skip only the account that is gone in ListRoleAssignmentsByRole. Before, one missing account folder made the result empty for all accounts. Only the graph user filter uses this function.

Tests

I wrote each test first and saw it fail:

  • TestSelfAssignFailsWhenAssignmentsCannotBeRead: the old code called WriteRoleAssignment after the read failed.
  • TestListRoleAssignmentsWithStaleDirCache: two CachedMDC instances (two pods) on one backend. The old code returned [].
  • TestListRoleAssignmentsByRoleSkipsGoneAccount: the old code returned [] and not 2 assignments.

Related issue

How has this been tested?

Types of changes

  • Bug fix

🤖 Generated with Claude Code

@2403905
2403905 requested a review from LukasHirt as a code owner November 18, 2026 17:14
@kw-security

kw-security commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@2403905
2403905 requested a review from a team November 18, 2026 17:25
… cannot read it

The settings service could remove the role of a user without an error.
An empty role list makes the proxy assign the default role "User".
WriteRoleAssignment deletes the old assignments first, so an Admin
becomes a User.

Changes:

- AssignRoleToUser in services/settings/pkg/service/v0/service.go fails
  closed. When ListRoleAssignments returns an error, the self-assignment
  returns an error and does not write.
- CachedMDC.SimpleDownload in
  services/settings/pkg/store/metadata/cache.go drops the cached listing
  of a folder when a file in it is gone. Another pod can change the
  folder, and that pod does not clear the caches of this pod.
- ListRoleAssignments in
  services/settings/pkg/store/metadata/assignments.go reads the account
  folder again after a stale listing.
- ListRoleAssignmentsByRole skips an account folder that is gone. Before,
  it returned an empty list for all accounts.

reva PR #820 fixes the cause in the metadata storage: each connection
error of a download became NotFound. A reva bump follows after that PR
is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@2403905
2403905 force-pushed the fix/8.0/OCISDEV-1714 branch from 2747d5b to 20720eb Compare November 18, 2026 17:29
@2403905
2403905 removed the request for review from LukasHirt November 18, 2026 17:41

This branch has not been deployed

No deployments
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.

2 participants