Skip to content

fix(bigquery): carry job location into page 2+ (getQueryResults) - #570

Open
igoramf wants to merge 1 commit into
mainfrom
fix/bigquery-page-location
Open

igoramf wants to merge 1 commit into
mainfrom
fix/bigquery-page-location

Conversation

@igoramf

@igoramf igoramf commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

bigquery_query page 2+ fails with 404 Not found: Job for any dataset outside the US/EU multi-regions (e.g. southamerica-east1).

Reproduced with a 3-row query and maxResults=1 against a southamerica-east1 dataset: page 1 works, and page 2 with the returned token 404s. bigquery_get_job on the same job also 404s without location and finds the job with it.

Cause: jobs.query (page 1) infers the region from the dataset, but jobs.getQueryResults (page 2+) looks the job up by id and needs location for non-US/EU jobs. The opaque pageToken stored only jobId + BQ token, which dropped jobReference.location, and getQueryResults never sent it.

Fix

  • The pageToken now carries jobReference.location. Legacy two-part tokens still decode.
  • getQueryResults sends location when it is known.
  • The job-completion polling loops pass it too.

Tests

  • New: location round-trips from page 1's token into page 2's URL. This test fails without the fix.
  • New: a legacy token without location still decodes.
  • bun test: 14 pass.

Summary by cubic

Fixes BigQuery queries 404ing with "Not found: Job" on page 2+ when the dataset is outside the US/EU multi-regions (e.g. southamerica-east1). The opaque page token now carries the job's location, and getQueryResults plus the job-completion polling loops send it when known. Legacy tokens without a location still decode.

Tests: new coverage verifies the location round-trips from page 1's token into page 2's request, and that legacy two-part tokens decode correctly.

Written for commit 4fc8062. Summary will update on new commits.

View guided diff Turn on auto-fix

The opaque pageToken kept only jobId + BQ token, and getQueryResults never
sent location, so page 2 of any job outside the US/EU multi-regions
(e.g. southamerica-east1) 404'd "Not found: Job". The token now carries
jobReference.location (legacy 2-part tokens still decode), and the
job-completion polling loops pass it too.
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/airtable November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/blog-generator November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/content-scraper November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/deco-llm November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/deco-news-weekly-digest November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/discord-read November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/figma-mcp November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/flux November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-analytics November 9, 2026 20:26 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-big-query November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-calendar November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-calendar-sa November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-drive November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-meet November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-search-console November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-sheets November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-slides November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-tag-manager November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/google-workspace November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/grafana November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/grain November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/hyperdx November 9, 2026 20:27 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/magento November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/meta-ads November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/nanobanana November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/object-storage November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/pandadoc November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/perplexity November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/registry November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/shopify November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/slack-mcp November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/veo November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/vtex November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/vtex-docs November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/wake November 9, 2026 20:28 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/whatsappagent November 9, 2026 20:29 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/youtube-channel-admin November 9, 2026 20:29 In progress
@deco-hosting
deco-hosting Bot requested a deployment to preview/pr-570/youtube-search November 9, 2026 20:29 In progress
@igoramf

igoramf commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: LGTM: the location now goes from jobs.query into the token and back out to every getQueryResults call (round 1)

Blocking

None.

Worth fixing

None that should hold this PR.

Checked, fine

  • Token format. The location is appended as a third field only when it is set. decodePageToken still accepts legacy two-part tokens. A job ID is limited to [A-Za-z0-9_-], and BigQuery location names have no newline in them, so splitting on \n is safe for both.
  • Every caller passes location. Both polling loops (queryAndWait, queryOnePage) and the page-2+ path in tools/bigquery.ts send it. getJob / bigquery_get_job already took location as an input. No other caller of getQueryResults or encodePageToken exists in the package.
  • US jobs. For these the location returned is US (or it is absent). Sending location=US is valid and matches the default.
  • The new test. It asserts that location=southamerica-east1 appears in the page-2 URL. Without the fix the token drops the location, so that assertion fails. The legacy-token test covers backward compatibility.
  • CI checks is green.

This branch is being deployed

38 in progress deployments
preview/pr-570/youtube-search — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/youtube-channel-admin — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/whatsappagent — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/wake — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/vtex-docs — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/vtex — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/veo — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/slack-mcp — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/shopify — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/registry — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/perplexity — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/pandadoc — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/object-storage — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/nanobanana — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/meta-ads — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/magento — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/hyperdx — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/grain — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/grafana — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-workspace — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-tag-manager — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-slides — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-sheets — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-search-console — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-meet — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-drive — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-calendar-sa — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-calendar — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-big-query — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/google-analytics — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/flux — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/figma-mcp — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/discord-read — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/deco-news-weekly-digest — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/deco-llm — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/content-scraper — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/blog-generator — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
preview/pr-570/airtable — 4fc80628 Deployed Nov 9, 2026 by deco-hosting[bot]
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.

2 participants