Repository navigation
fix(graph): keep the permissions list query options with $top=0 - #4035
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage 100.00% diff coverage · +0.01% coverage variation
Metric Results Coverage variation ✅ +0.01% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (2032e85) 94240 28200 29.92% Head commit (ccba4a5) 94238 (-2) 28208 (+8) 29.93% (+0.01%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#4035) 4 4 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
I checked which of our clients could be affected by the new
So rejecting any other |
|
@pbleser-oc Thanks for checking the clients. Agreed. |
pbleser-oc
left a comment
There was a problem hiding this comment.
Thanks, the fix looks good to me, and the tests cover the requests of the web client well. None of our clients is affected by the new 400 for a $top other than 0, see my comment above for the details.
Description
The permissions list endpoints (
GET …/items/{itemId}/permissionsandGET …/root/permissions) dropped all query options when the request contained$top, except for$count=true&$top=0.getListPermissionsQueryOptionsreturned empty options together with a nil error in that case, so$select,$filterand$countwere silently ignored and the full listing was returned with status200.With this change:
$top=0with$count=true$top=0without$count=true$top=0is ignored, the other query options are kept$topother than0400 invalidRequest: only$top=0is supportedRelated Issue
$topmakes the permissions list ignore$selectand$filter#4018Motivation and Context
The web client sends
$top=0with every permissions request. Because of this bug:[email protected], were computed together with the full share listing of the space;$filter, were the roles for internal users, e.g. "Can upload".Why
$top=0without$count=trueis ignored$topexists on this endpoint for one purpose:$count=true&$top=0returns only the number of permissions, e.g. for the member count of a space. Returning only the first n permissions is not supported, as the permissions have no stable order and there is no paging.Strictly,
$top=0means "zero entries". But the web client also sends$top=0when it lists the shares of a resource in the sharing panel and needs all of them. Returning zero entries, or rejecting$top=0, would break the sharing panel. Ignoring$top=0without$count=truekeeps the sharing panel working as before and makes$selectand$filtertake effect. No web change is needed.Why other values of
$topare rejectedThe server cannot return only the first n permissions. Answering
$top=5with all permissions misleads the client, so it is rejected with400, like an unsupported$filter. None of the opencloud-eu clients (web, desktop, android, ios) sends such a value.Impact
$topother than0now fail with400instead of returning all permissions.How Has This Been Tested?
$top=0without$count=truekeeps$select, the federated roles filter and the filter without link permissions, also with$count=falseand on the space root endpoint (failing before the change);$topother than0, also negative, with$count=trueor with$select, is rejected with400without calling the service (failing before the change);$top=0alone still lists all permissions, and a$topthat is not a number is still rejected.apiSharingNg1/listPermissions.feature:$top=0alone and together with$selectand the federated roles filter on a folder,$selectwith$top=0on a project space, and400for$top=5,$top=5&$count=trueand$top=-1.$count=true&$top=0, which still returns only the number.go test ./services/graph/...passes in all 11 packages;go test -race ./services/graph/pkg/service/v0/passes.gofmtandgit diff --checkare clean.go vetreports no new findings.golangci-lint. CI will be the first to run them.Types of changes
Checklist:
AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and this description; I reviewed and adjusted them.