RyoKusnadi commented on issue #9417:
URL: https://github.com/apache/devlake/issues/9417#issuecomment-7044513286

   Hi @DoDiODev @klesh, can I do it?
   
   How I plan to do it:
   1. 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.
   2. 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.
   3. `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.
   4. `Post` stays as it is (it sets the connection id on a new row).
   5. 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to