Skip to content

fix: retry gateway URL resolution in configureManualApproval - #58

Open
breken-ai wants to merge 1 commit into
onecli:mainfrom
breken-ai:fix/approval-gateway-url-retry
Open

breken-ai wants to merge 1 commit into
onecli:mainfrom
breken-ai:fix/approval-gateway-url-retry

Conversation

@breken-ai

Copy link
Copy Markdown

What is the current behavior?

ApprovalClient.start() resolves the gateway URL once, before the poll loop:

const gatewayUrl = await this.resolveGatewayUrl(projectId);
while (this.running) { ... }

When ONECLI_GATEWAY_URL isn't set and GET /v1/gateway-url fails (OneCLI not up yet, a 5xx, a network error), start() rejects. configureManualApproval catches that rejection and drops it, so polling never starts. The handle looks normal, nothing is logged, and no approval reaches the callback until the process restarts. Held requests just wait until they time out.

The comment in configureManualApproval says "Errors handled internally with backoff", and that's already true for poll failures. OrgApprovalClient.start() also resolves inside its loop for this reason.

What is the new behavior?

The resolution moves inside the try in the loop, the same way OrgApprovalClient does it. A failed resolution now takes the existing 5s backoff and is retried. resolveGatewayUrl still caches on success, so once it resolves, each poll does no extra work.

Additional context

test/approvals/client.test.ts goes through OneCLI.configureManualApproval. The first /v1/gateway-url call returns 503, the second returns the gateway URL, and the first poll returns one pending request. The test checks that resolution is retried after the backoff and that the callback receives the request.

Checked locally on Node 22 with pnpm 10.30.1:

Check Result
New test against unpatched main (6579233) failed: expected 1 to be 2 (no retry, callback never called)
New test with this change passed
pnpm test 132 passed (11 files)
pnpm typecheck passed
pnpm build passed

Not tested against a running OneCLI instance.

The project approval loop resolved the gateway URL once before the
loop, so a failed GET /v1/gateway-url rejected start(), which
configureManualApproval swallows. Polling never started and approvals
were never delivered. Resolve inside the loop, like OrgApprovalClient,
so it backs off and retries.
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