agentic-community / agentic-community/mcp-gateway-registry
PATCH /api/servers/{path} fails and uses non-atomic full-card write on MongoDB CE
- Lingua principale
- Python
- Stelle
- 911
- Fork
- 234
- Merge medio
- 1g 11h
- PR unite (30g)
- 62
Descrizione
## Observed
On registry image version 1.29.0 / source revision `66d1945b6e91531512f44649e36a6bfc5c798af2`, an authenticated registry-admin M2M request to `PATCH /api/servers/{path}` returns HTTP 500 with `Failed to save server` for a description-only JSON merge patch. The card exists and is readable.
There is a second, independent correctness problem at that revision. `patch_server_endpoint` reads the complete card and merges the narrow client payload, then `server_service.update_server` reaches a Mongo repository update that performs an unconditional full-card `$set`. A concurrent egress OAuth, credential, or other card update can be overwritten even though the client omitted that field.
This blocks Git reconciliation of existing-card metadata and tool inventory. A full-card PUT has the same lost-update problem. A client-side `If-Match` check before the repository call is not race-proof unless the compare participates atomically in the repository write.
## Expected
A description-only PATCH returns 2xx and persists only that field. The same endpoint accepts `tool_list` / `num_tools` while preserving absent and concurrently updated auth, OAuth, egress, credential, and server-managed fields.
The persistence primitive must be either:
- an atomic field-scoped `$set` containing only fields present in the validated patch; or
- a repository-level compare-and-set whose version/revision predicate and write are one atomic database operation.
## Relevant source path
`registry/api/server_routes.py::patch_server_endpoint` reads and merges the card before `server_service.update_server(path, merged)`. The MongoDB CE repository then performs the write; the current route collapses a false return to the 500 and does not expose the underlying exception.
## Acceptance
- description-only PATCH succeeds as an admin identity
- tool-list growth succeeds
- the repository write is field-scoped or atomic-CAS, not read/merge plus unconditional full-card `$set`
- a concurrent update to an omitted credential/OAuth/egress field cannot be lost (persistence-level concurrency regression test)
- any `If-Match`/revision contract is enforced in the same repository operation as the write
- a repeated identical PATCH is harmless
- focused MongoDB CE route and repository regression coverage
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.