You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug][Framework] PATCH scope-configs silently moves a scope config to the connection in the URL #9417
I had searched in the issues and found no similar issues.
What happened
PATCH /plugins/{plugin}/connections/{connectionId}/scope-configs/{scopeConfigId}
does not check that the scope config belongs to {connectionId}. Instead, DsScopeConfigApiHelper.Patch copies the connectionId from the URL into the
request body before saving:
So a PATCH with a mismatching connection ID returns 200 and silently
reassigns the scope config to the other connection. Afterwards:
the scope config no longer shows up under its own connection in Config UI
(GET .../connections/{own}/scope-configs no longer lists it),
it shows up under the foreign connection instead,
scopes of the original connection still reference it via scope_config_id,
so data collection keeps working and the problem goes unnoticed.
We hit this with the Jira plugin while updating several scope configs via
the API with a copy-pasted URL: all of them ended up under one connection.
What do you expect to happen
PATCH should not change the owning connection. If the scope config does not
belong to the connection in the URL, the API should respond with 404
(or 400). Alternatively, connectionId should be ignored on PATCH.
How to reproduce
Create two connections of the same plugin, e.g. Jira connection 1 and 2.
Create a scope config under connection 1 (say id 5).
GET /plugins/jira/connections/1/scope-configs no longer lists id 5; GET /plugins/jira/connections/2/scope-configs does.
Anything else
Happens every time. It affects every plugin that uses DsScopeConfigApiHelper,
not only Jira. Found on PostgreSQL, but the behaviour is database independent.
In backend/helpers/pluginhelper/api/ds_scope_config_api_helper.go, DsScopeConfigApiHelper.Patch writes the URL's connectionId into the body before patching, so the row moves to that connection. I'd load the scope config first and compare its ScopeConfigConnectionId() with the URL's connection id.
On a mismatch, return a not-found error and leave the row alone. Drop the input.Body["connectionId"] = connectionId line so a PATCH can't change the owner.
GetDetail, Delete and GetProjectsByScopeConfig in the same helper also look up by scope config id only, so I'd add the same check there to keep them consistent.
Post stays as it is (it sets the connection id on a new row).
Tests in the same package with mockdal: PATCH with the wrong connection gets 404 and nothing is written, PATCH with the right connection still updates (must not change), GET and DELETE with the wrong connection get 404.
404 vs 400 for the mismatch is up to you, I'd go with 404.
Activity
RyoKusnadi commentedon Nov 20, 2026
Hi @DoDiODev @klesh, can I do it?
How I plan to do it:
backend/helpers/pluginhelper/api/ds_scope_config_api_helper.go,DsScopeConfigApiHelper.Patchwrites the URL'sconnectionIdinto the body before patching, so the row moves to that connection. I'd load the scope config first and compare itsScopeConfigConnectionId()with the URL's connection id.input.Body["connectionId"] = connectionIdline so a PATCH can't change the owner.GetDetail,DeleteandGetProjectsByScopeConfigin the same helper also look up by scope config id only, so I'd add the same check there to keep them consistent.Poststays as it is (it sets the connection id on a new row).mockdal: PATCH with the wrong connection gets 404 and nothing is written, PATCH with the right connection still updates (must not change), GET and DELETE with the wrong connection get 404.404 vs 400 for the mismatch is up to you, I'd go with 404.