Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-api): treat a reauth mark that matched no row as a lost race (#753)
Alfredo Lopez84b8cc8cd831
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex c0f7b6769..7c2a1ed14 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.611",+ "version": "0.1.612","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.611",+ "version": "0.1.612","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex b9757d8d4..7480cba97 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.611",+ "version": "0.1.612","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/services/codexSubscriptionOAuth.ts b/control-api/src/services/codexSubscriptionOAuth.tsindex df68986fa..e9fb0bb50 100644--- a/control-api/src/services/codexSubscriptionOAuth.ts+++ b/control-api/src/services/codexSubscriptionOAuth.ts@@ -789,7 +789,20 @@ async function exchangeRefreshToken('invalid_grant observed after a lost refresh race')}- await markCodexRefreshRejected(deps.db, fence.connectionKey, fence.expectedRevision)+ const marked = await markCodexRefreshRejected(+ deps.db,+ fence.connectionKey,+ fence.expectedRevision+ )+ // The fenced UPDATE matched nothing: the grant was revoked or replaced+ // after the check above, so this is the same lost race and the row was+ // not written.+ if (!marked) {+ throw new CodexSubscriptionOAuthError(+ 'stale_revision',+ 'invalid_grant observed after the grant changed'+ )+ }// The row is now `reauth_required`. The throw below must not read as// "nothing happened": the ConfigMap carries this status, so whoever// catches this owes a republish.