Skip to content

fix: backfill empty entitlement account_id from DCR and retry on 5xx#321

Open
luis5tb wants to merge 2 commits into
RHEcosystemAppEng:mainfrom
luis5tb:worktree-db-inconsistency
Open

fix: backfill empty entitlement account_id from DCR and retry on 5xx#321
luis5tb wants to merge 2 commits into
RHEcosystemAppEng:mainfrom
luis5tb:worktree-db-inconsistency

Conversation

@luis5tb

@luis5tb luis5tb commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

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

@luis5tb luis5tb force-pushed the worktree-db-inconsistency branch from 2524477 to e3c11db Compare July 8, 2026 08:53
luis5tb and others added 2 commits July 10, 2026 15:14
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>
@luis5tb luis5tb force-pushed the worktree-db-inconsistency branch from e3c11db to d015678 Compare July 10, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant