fix: backfill empty entitlement account_id from DCR and retry on 5xx#321
Open
luis5tb wants to merge 2 commits into
Open
fix: backfill empty entitlement account_id from DCR and retry on 5xx#321luis5tb wants to merge 2 commits into
luis5tb wants to merge 2 commits into
Conversation
2524477 to
e3c11db
Compare
Previously, 5xx responses from the Procurement API when resolving account IDs were silently swallowed (logged as warning, returned None). This meant the entitlement was created with an empty account_id and Pub/Sub considered the event handled (200 response), never retrying. Now 5xx responses raise RuntimeError (same pattern as network errors), causing the handler to fail and Pub/Sub to retry the event. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The dcr_clients table always has a valid account_id (from the JWT sub claim), but marketplace_entitlements often has account_id='' because Pub/Sub events rarely include account info. Add backfill_entitlement_account_id() to ProcurementService and call it during DCR register_client() — every DCR request now writes the JWT's authoritative account_id back to the entitlement if it was previously empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e3c11db to
d015678
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backfill marketplace_entitlements.account_id from the DCR JWT's sub claim when it's empty — the dcr_clients table always has a valid account_id but entitlements often don't because Pub/Sub events rarely include account info
Raise RuntimeError on 5xx responses in _resolve_account_id() so Pub/Sub retries the event instead of silently creating entitlements with empty account_id