fix(cloudflare): correct browser-rendering getCrawl response schema#331
Open
k3dom wants to merge 1 commit into
Open
fix(cloudflare): correct browser-rendering getCrawl response schema#331k3dom wants to merge 1 commit into
k3dom wants to merge 1 commit into
Conversation
The upstream Cloudflare TypeScript SDK types for the getCrawl operation do not match what the API actually returns: - `records[].metadata` is typed as required, but Cloudflare omits it for records that have not completed (queued/skipped/cancelled/...), causing decode failures while polling an in-progress crawl. - `cursor` is typed as a string, but the API returns a number (the next record index). It is absent on the last page. Adds a patch file for the operation and regenerates the service. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Disclaimer
This PR was fully generated using Claude Code. I however have been running these exact schema fixes as a
pnpm patchagainst@distilled.cloud/cloudflareas crawls and can confirm they match the live API behavior.Problem
The upstream
cloudflare-typescriptSDK types forbrowser-rendering'sgetCrawloperation don't match what the API actually returns, so decoding real responses fails:records[].metadatais typed as required, but Cloudflare omits it for records that have not completed yet (queued/skipped/cancelled/...). Polling an in-progress crawl job therefore fails to decode with aParseErroruntil every record has finished.cursoris typed asstring, but the API returns a number (the next record index for pagination). It is absent on the last page.Example of a real response that the current schema rejects:
{ "result": { "id": "...", "browserSecondsUsed": 12, "finished": 3, "records": [ { "status": "queued", "url": "https://example.com/page" } ], "skipped": 0, "status": "running", "total": 10, "cursor": 50 } }Fix
Adds
patches/browser-rendering/getCrawl.jsonusing the existing patch mechanism:{ "response": { "properties": { "records[].metadata": { "optional": true }, "cursor": { "type": "number", "nullable": true } } } }and regenerates the service (
bun run generate). Only thegetCrawlschema changes; the emittedspecs/cloudflare/browser-rendering.openapi.ymlis updated to match. Unrelated drift the generator produced in other emitted specs (containers/r2/secrets-store/workers info titles) was intentionally left out of this PR.bun run check(tsgo + oxlint + oxfmt) passes.Non-issues
Two other discrepancies between the live API and the SDK types were verified to not need patching:
metadatakeys (og:*,lastModified, ...) — the API returns more metadata fields than the SDK declares, but effect Schema's default decode ignores unknown keys, so they pass through without error.running,cancelled_by_user) — the top-level jobstatusis a plainSchema.String(not a literal union), so these decode fine as-is.