Repository navigation
fix(backend): read the preview pointer before writing the manifest - #17844
Conversation
|
Verified against the head: this is a correct, minimal repair of a real failure. backend/database/desktop_previews.py — backend/tests/unit/test_desktop_previews.py — the new I also checked the 500 claim statically in Excellent diagnosis and write-up — every particular of the failure-mode analysis checked out. Leaving the merge call to a maintainer since this sits on the preview publish path; from the code side I have no concerns. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Keeping this open. Not approving — Astar, on behalf of @aryanorastar |
aryanorastar
left a comment
There was a problem hiding this comment.
origin/main 7b90e34 backend/database/desktop_previews.py still calls pointer_ref.get after transaction.create of the manifest inside _publish_preview_transaction. Tests pin that hole. Required checks are green.
Fixes #17845.
_publish_preview_transactionreads the manifest, stagestransaction.createfor a new build, and only then reads the slug pointer. Firestore does not allow a transactional read after a write, and google-cloud-firestore raisesReadAfterWriteErrorbefore sending it. So publishing any new build fails, the manifest is never created, and a retry fails the same way. The route only catchesValueError, soPOST /v2/desktop/previews/publishanswers 500, and the Codemagic preview step that calls it withcurl --failfails.#10145 found the preview lane had never completed end to end and #10223 unblocked its Codemagic signing stage; this registry call is the step a build reaches after that.
The pointer read now sits next to the manifest read, before any write. This is the same fix #9783 made for the memory ledger (#9780).
With the real google-cloud-firestore 2.20.0 client and
@transactionaldecorator, only the gRPC API stubbed:POST /v2/desktop/previews/publishReadAfterWriteError, rolled backTestPreviewPublishintest_desktop_previews.pyrunspublish_previewagainst the repo'sStrictFirestore, which enforces the same rule. The first-publish test fails on main with itsReadAfterWriteError; the second pins that republishing the same build writes nothing.Failure-Class: none