Skip to content

feat: automatically poll GET endpoint on 202 with exponential backoff#527

Open
praneetloke wants to merge 4 commits intomainfrom
claude/issue-262-20260224-0601
Open

feat: automatically poll GET endpoint on 202 with exponential backoff#527
praneetloke wants to merge 4 commits intomainfrom
claude/issue-262-20260224-0601

Conversation

@praneetloke
Copy link
Member

Closes #262

Changes

When a Create or Update returns HTTP 202 (Accepted), the provider polls the GET endpoint:

  • Polling continues only while GET returns 404 (resource not yet created), stopping when GET returns 200 (resource exists)
  • Uses exponential backoff starting at 1s, doubling each attempt, capped at 30s
  • Timeout from CreateRequest/UpdateRequest (defaults to 10 minutes)
  • For Create: 202 response body merged into inputs for path param resolution
  • For Update: oldState used for path param resolution

Generated with Claude Code

When a Create or Update request returns HTTP 202 (Accepted), the
provider now polls the GET endpoint from the CRUD map until the
resource is ready:

- Polling continues only while GET returns 404 (resource not yet
  created), stopping when GET returns 200 (resource exists).
- Uses exponential backoff starting at 1s, doubling each attempt,
  capped at 30s to avoid overwhelming the cloud provider API.
- Timeout is taken from the CreateRequest/UpdateRequest.Timeout
  field (defaults to 10 minutes if unset).
- For Create: the 202 response body is merged into inputs so that
  path params (e.g. resource ID) can be resolved for the GET URL.
- For Update: oldState is used for path param resolution.

Adds three test cases covering:
- Create 202: happy path (404 x2, then 200)
- Create 202: timeout when resource never becomes ready
- Update 202: happy path (404 x1, then 200)

Closes #262

Co-authored-by: Praneet Loke <praneetloke@users.noreply.github.com>
@praneetloke praneetloke force-pushed the claude/issue-262-20260224-0601 branch from 285b33b to cbc3753 Compare February 24, 2026 20:12

pollOutputs, pollErr := p.pollResourceUntilReady(ctx, *crudMap.R, inputs, pollTimeout)
if pollErr != nil {
return nil, errors.Wrap(pollErr, "polling resource after 202 response")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should return the outputs we have from the initial POST request, since the resource was accepted but just not yet ready. The output should contain the resource ID from the server which can be used to refresh the state.

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.

Automatically poll the read endpoint for a resource for 202 status codes

1 participant