fix: return fresh devKey document from update endpoint#11920
fix: return fresh devKey document from update endpoint#11920yogeshwaran-c wants to merge 1 commit intoappwrite:1.9.xfrom
Conversation
The devKey update action mutated the in-memory $key via setAttribute and then wrote a sparse Document, but did not capture the return of updateDocument. The response therefore returned a stale $updatedAt taken from the pre-update fetch. Drop the redundant setAttribute chain and reassign $key from the updateDocument return, matching the pattern used by sibling Update actions (e.g. Project/Keys/Update, Project/Platforms/*/Update).
Greptile SummaryThis PR fixes a stale-response bug in the dev key update endpoint where the response was rendered from the pre-update in-memory document rather than the freshly persisted one. The fix assigns the Confidence Score: 5/5Safe to merge — single-line fix with no side effects, corrects a response-staleness bug. The change is minimal, correct, and consistent with the established pattern across the codebase. No P0 or P1 issues found; all remaining behaviour (cache purge, response rendering) is preserved. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: capture updated devKey document to ..." | Re-trigger Greptile |
Summary
PUT /v1/projects/:projectId/dev-keys/:keyId(Projects/Http/DevKeys/Update.php) currently mutates the in-memory$keyviasetAttribute('name')/setAttribute('expire')and issues a sparseupdateDocument(), but does not capture the updated document thatupdateDocument()returns. The response is then rendered from the pre-update$key, so the client receives a stale$updatedAt(and any other server-maintained fields like internal sequences would be out of date as well).This assigns the
updateDocument()return back to$keyand drops the now-redundantsetAttributechain, matching the pattern already used byProject/Http/Project/Keys/Update.php, everyProject/Http/Project/Platforms/*/Update.php, and the cloud/account variants that were aligned during #11465.Before
After
Test plan
PUT /v1/projects/:projectId/dev-keys/:keyIdreturns a$updatedAtthat reflects the write (no longer equal to$createdAt/ last value fromgetDocument).nameandexpirestill reflect the request payload.$dbForPlatform->purgeCachedDocument('projects', $project->getId())is still called after the update.