Skip to content

fix(batchrouter): abort bq stream all events jobs on terminal auth failures - #7548

Merged
shekhar-rudder merged 7 commits into
masterfrom
harness/RUD-3434-fix-batchrouter-abort-bq-stream-e34b6c23
Nov 2, 2026
Merged

shekhar-rudder merged 7 commits into
masterfrom
harness/RUD-3434-fix-batchrouter-abort-bq-stream-e34b6c23

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

For RUD-3434: abort BQSTREAM_ALL_EVENTS jobs when the service-account credentials themselves are rejected, instead of retrying them until job expiry.

Both BigQuery clients authenticate through option.WithAuthCredentialsJSON, so a rejected key surfaces from the REST schema calls as *auth.Error (cloud.google.com/go/auth), wrapped in a *url.Error. That is not an *oauth2.RetrieveError, and its text does not start with oauth2: cannot fetch token:. On master, shouldAbort therefore returned false, and the upload's first step (the schema fetch) failed retryably every cycle.

shouldAbort now also aborts on the three credential failures reproduced against the real Google endpoints:

  • *auth.Error whose token-endpoint body is invalid_grant (e.g. an unknown key or account).
  • An unparseable private key. The auth library flattens it to a string inside the HTTP transport's *url.Error, so only that inner error is matched; other error text can carry event values.
  • An incompatible credential type, marked with ErrIncompatibleCredentials where the REST client rejects it (message unchanged).

The existing gRPC code list is unchanged. There is no upfront credential validation; everything is classified from the Upload error.

Linear Ticket

RUD-3434

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Validation

  • go test -count=1 ./router/batchrouter/asyncdestinationmanager/bqstreamallevents/... passes. golangci-lint v2.14.0: 0 issues.
  • Probed Upload in-process against the real Google endpoints at 88f9b12f9: an unregistered key (invalid_grant), a malformed key and an authorized_user credential each abort on the first attempt.
  • End-to-end on a local stack (rudder-server built from source, events sent through the gateway to a BQSTREAM_ALL_EVENTS destination with fake credentials):
rudder-server build job state after first upload
master failed, attempt 1 (retried)
this PR before this push (a379860bf) failed, attempt 1 (retried)
this PR (2a79ca18c) aborted; master's failed jobs were also aborted on their next attempt

Known review findings

  • Any invalid_grant aborts, including Google's host-clock-skew variant ("Check your iat and exp values"). That case could not be reproduced locally, so it is not special-cased.
  • gRPC codes.Unauthenticated is still always terminal (unchanged from master).
  • The older BQSTREAM producer has a separate classifier and is not touched here.

🤖 Generated with Claude Code

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from task RUD-3434.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

The Correct generated files job failed because make fmt ran Go 1.27's go fix, which rewrote the joined-error loop in schemautils.go to slices.ContainsFunc; the subsequent git diff --exit-code found that uncommitted formatter change. I committed the exact rewrite and pushed it.

Validation: make fmt left only the intended diff, go test -count=1 ./router/batchrouter/asyncdestinationmanager/bqstreamallevents/... passed, go build passed, and golangci-lint reported 0 issues. The local make lint run stopped later at gitleaks, which reported 34 findings while scanning the two commits present before this formatter commit.

a379860

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

The Tests run failed in TestIntegration/Event_flow/Upload_Job_with_Role: the log reports WARNING: DATA RACE for concurrent accesses in gosnowflake/v2 v2.3.0 (*transportFactory).createTransport at transport.go:188, followed by testing.go:1867: race detected during execution of test. The All job failed because warehouse-integration failed; its other required groups succeeded.

This is an unrelated race in the Snowflake driver path. This branch changes only BQSTREAM_ALL_EVENTS files, and the Snowflake driver and warehouse code are unchanged. Resolving it needs a separately validated upstream driver or Snowflake concurrency fix, so I made no code change or push for this run.

shekhar-rudder and others added 2 commits October 29, 2026 14:48
…alidate credentials upfront

Both BigQuery clients authenticate through cloud.google.com/go/auth, so a
rejected service-account key reaches shouldAbort as *auth.Error, never as
*oauth2.RetrieveError or the flattened oauth2 text. Classify that type, and
validate credentials at the start of Upload, where the REST schema fetch would
otherwise fail first with an untyped error and retry.

Drop the writer-only preflight and terminal sentinel, the flattened-text
matching (grpc already reports per-RPC credential failures as Unauthenticated),
and the REST 400 abort with its carve-outs, which is not an auth failure.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Google also reports a skewed host clock as invalid_grant. Abort only when
the description names the key or account, so a pod with a drifting clock
does not abort every upload it handles.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

This Tests run has three independent failures outside the BQSTREAM_ALL_EVENTS change:

  • Integration (oss) panicked in enterprise/reporting.(*Mediator).DatabaseSyncer with sync: WaitGroup is reused before previous Wait has returned (mediator.go:131).
  • Package Unit (services/rsources) could not start its Postgres test dependency because Docker Hub returned 500 Internal Server Error while fetching a postgres image blob.
  • Package Unit (integration_test/partitionmigration) failed legacy_no_jobsdb_fanout: the webhook received 10,575 of 11,575 accepted events after the five-minute wait. The log shows one user's event index jumping from 1305 to 2306, but does not establish where the 1,000 events were lost.

All failed because the integration and package-unit groups failed. The branch changes only BQSTREAM_ALL_EVENTS files and a direct/indirect declaration for an existing Google auth dependency; it changes none of these failing paths. Docker Hub's 500 is external, and the reporting lifecycle and partition loss require separate, validated fixes. I made no code change or push for this run.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.67%. Comparing base (902160f) to head (656d364).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7548      +/-   ##
==========================================
- Coverage   84.70%   84.67%   -0.04%     
==========================================
  Files         631      631              
  Lines       62941    62950       +9     
==========================================
- Hits        53317    53302      -15     
- Misses       9621     9645      +24     
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

shekhar-rudder and others added 3 commits October 29, 2026 18:19
…vely

Drop the upfront credential validation in Upload and abort from the Upload
error instead:

- an incompatible credential type is marked with ErrIncompatibleCredentials
  where the REST client and the stream writer reject it (message unchanged)
- an unparseable key is matched only inside the HTTP transport error, where
  the auth library flattens it to a string; other error text can carry event
  values and is never matched

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ions

Abort on invalid_grant, an unparseable key and an incompatible credential type,
each reproduced against the real endpoints. Drop the REST 401/403 handling and
its throttling carve-outs, invalid_client/unauthorized_client, the invalid_grant
description allowlist, the joined-error walk and the stream-writer sentinel:
none of them was observed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ldAbort's default case

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@shekhar-rudder
shekhar-rudder marked this pull request as ready for review October 29, 2026 13:36
Copilot AI balanced review requested due to automatic review settings October 29, 2026 13:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the credential-error classification change.

No open issues 🎉

What changed in this PR

This PR updates BQSTREAM_ALL_EVENTS error classification so jobs abort on rejected service-account credentials instead of retrying until expiry. Existing gRPC error handling remains unchanged.

Changes:

  • Recognizes invalid_grant, malformed private keys, and incompatible credential types as terminal failures.
  • Adds classifier tests and an Upload-level test for terminal authentication failures.
  • Promotes the existing Google auth dependency from indirect to direct.
File Description
warehouse/​integrations/​bigquery/​bigquery.go Adds a sentinel error for incompatible credentials while preserving the error message.
router/​batchrouter/​asyncdestinationmanager/​bqstreamallevents/​schemautils.go Classifies the additional credential failures as terminal.
router/​batchrouter/​asyncdestinationmanager/​bqstreamallevents/​schemautils_test.go Tests terminal credential errors and retryable cases.
router/​batchrouter/​asyncdestinationmanager/​bqstreamallevents/​bqstreamallevents_test.go Verifies Upload aborts jobs after a terminal token error.
go.mod Marks Google auth as a direct dependency without changing its version.

Review effort: Balanced

@rudder-devbox

rudder-devbox Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

The Snowflake integration test failed under -race: TestIntegration/Event_flow/Upload_Job_with_use_rudder_storage logged WARNING: DATA RACE for concurrent read/write access in gosnowflake/[email protected] (*transportFactory).createTransport at transport.go:188, then testing.go:1867: race detected during execution of test. The All job failed only because warehouse-integration failed; its other required groups passed.

This reproduces the same upstream Snowflake driver race seen in the earlier run, now in a different subtest. This branch changes no Snowflake driver or warehouse code, so there is no BQSTREAM_ALL_EVENTS fix to push for it. It requires a separately validated driver or Snowflake concurrency fix. I made no code change or push for this run.

@rudder-devbox

rudder-devbox Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

⚠ I finished here but didn't post a reply on this item.

2 similar comments
@rudder-devbox

rudder-devbox Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

⚠ I finished here but didn't post a reply on this item.

@rudder-devbox

rudder-devbox Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

⚠ I finished here but didn't post a reply on this item.

@shekhar-rudder
shekhar-rudder merged commit 6b7e023 into master Nov 2, 2026
232 of 240 checks passed
@shekhar-rudder
shekhar-rudder deleted the harness/RUD-3434-fix-batchrouter-abort-bq-stream-e34b6c23 branch November 2, 2026 06:50
atzoum pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.93.0-rc.1](v1.92.0...v1.93.0-rc.1)
(2026-11-09)


### Features

* **destination:** recognize machine_oauth accounts as oauth
([#7549](#7549))
([f51e4ca](f51e4ca))
* incremental definitions on the v2 namespace config
([#7487](#7487))
([ce51e38](ce51e38))
* **processor:** add flag to abort python transformations on deployments
that do not offer them
([#7571](#7571))
([ca85eb2](ca85eb2))
* **processor:** filter http v2 events by destination message types
([#7538](#7538))
([58fd176](58fd176))
* **processor:** send the workspace id to per-workspace pyt pods
([#7551](#7551))
([ea33835](ea33835))
* **warehouse:** add maxcompute destination
([#7568](#7568))
([a64bfd9](a64bfd9))


### Bug Fixes

* **batchrouter:** abort bq stream all events jobs on terminal auth
failures
([#7548](#7548))
([6b7e023](6b7e023))
* bump andybalholm/brotli to v1.2.7 [SEC-759]
([#7525](#7525))
([6dfe468](6dfe468))
* bump rudder-go-kit to v0.84.3
([#7547](#7547))
([355054a](355054a))
* **core:** schema forwarder panics on shutdown
([#7519](#7519))
([dd61cfc](dd61cfc))
* database connections hang when context is cancelled during a copy
([#7578](#7578))
([8dae6e3](8dae6e3))
* **jobsdb:** compaction missing pairs after one that doesn't fit
([#7574](#7574))
([573271b](573271b))
* **jobsdb:** multiconsumer recovery misses a consumer's executing
status after another consumer's later status
([#7554](#7554))
([69b43e0](69b43e0))
* **jobsdb:** old jobs not expiring for every consumer
([#7573](#7573))
([366f114](366f114))
* **jobsdb:** pickups stalling on status tables with skewed stats
([#7572](#7572))
([318446f](318446f))
* **jobsdb:** unionjobsdb functions pick the first datasets by table
name ([#7558](#7558))
([e94d6c5](e94d6c5))
* **router:** event order test only counts drained jobs of the last
dataset
([#7552](#7552))
([b0a097a](b0a097a))
* **router:** mask secrets in array-shaped reporting samples
([#7536](#7536))
([902160f](902160f))
* **warehouse:** hot-reload degraded workspaces without aborting
restored uploads
([#7564](#7564))
([cb98598](cb98598))
* **warehouse:** match deltalake columns case-insensitively
([#7563](#7563))
([a7d30d7](a7d30d7))
* **warehouse:** migrate snowflake to gosnowflake v2.3.0
([#7542](#7542))
([cc09426](cc09426))
* **warehouse:** skip job-creation error log on router shutdown
([#7567](#7567))
([895367e](895367e))


### Miscellaneous

* **deps:** bump github.com/go-jose/go-jose/v4 from 4.1.4 to 4.1.6
([#7545](#7545))
([35ee952](35ee952))
* export only the +Inf bucket for limiter timers
([#7570](#7570))
([4429472](4429472))
* **router:** add drainReason label to pipeline_processed_events
([#7561](#7561))
([af0aef8](af0aef8))
* sync release v1.92.0 to main branch
([#7534](#7534))
([9ab165d](9ab165d))
* **warehouse:** bump sqlconnect-go to v1.37.1
([#7575](#7575))
([acdad67](acdad67))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
atzoum pushed a commit that referenced this pull request Nov 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.93.0](v1.92.0...v1.93.0)
(2026-11-09)


### Features

* **destination:** recognize machine_oauth accounts as oauth
([#7549](#7549))
([f51e4ca](f51e4ca))
* incremental definitions on the v2 namespace config
([#7487](#7487))
([ce51e38](ce51e38))
* **processor:** add flag to abort python transformations on deployments
that do not offer them
([#7571](#7571))
([ca85eb2](ca85eb2))
* **processor:** filter http v2 events by destination message types
([#7538](#7538))
([58fd176](58fd176))
* **processor:** send the workspace id to per-workspace pyt pods
([#7551](#7551))
([ea33835](ea33835))
* **warehouse:** add maxcompute destination
([#7568](#7568))
([a64bfd9](a64bfd9))


### Bug Fixes

* **batchrouter:** abort bq stream all events jobs on terminal auth
failures
([#7548](#7548))
([6b7e023](6b7e023))
* bump andybalholm/brotli to v1.2.7 [SEC-759]
([#7525](#7525))
([6dfe468](6dfe468))
* bump rudder-go-kit to v0.84.3
([#7547](#7547))
([355054a](355054a))
* **core:** schema forwarder panics on shutdown
([#7519](#7519))
([dd61cfc](dd61cfc))
* database connections hang when context is cancelled during a copy
([#7578](#7578))
([8dae6e3](8dae6e3))
* **jobsdb:** compaction missing pairs after one that doesn't fit
([#7574](#7574))
([573271b](573271b))
* **jobsdb:** multiconsumer recovery misses a consumer's executing
status after another consumer's later status
([#7554](#7554))
([69b43e0](69b43e0))
* **jobsdb:** old jobs not expiring for every consumer
([#7573](#7573))
([366f114](366f114))
* **jobsdb:** pickups stalling on status tables with skewed stats
([#7572](#7572))
([318446f](318446f))
* **jobsdb:** unionjobsdb functions pick the first datasets by table
name ([#7558](#7558))
([e94d6c5](e94d6c5))
* **router:** event order test only counts drained jobs of the last
dataset
([#7552](#7552))
([b0a097a](b0a097a))
* **router:** mask secrets in array-shaped reporting samples
([#7536](#7536))
([902160f](902160f))
* **warehouse:** hot-reload degraded workspaces without aborting
restored uploads
([#7564](#7564))
([cb98598](cb98598))
* **warehouse:** match deltalake columns case-insensitively
([#7563](#7563))
([a7d30d7](a7d30d7))
* **warehouse:** migrate snowflake to gosnowflake v2.3.0
([#7542](#7542))
([cc09426](cc09426))
* **warehouse:** skip job-creation error log on router shutdown
([#7567](#7567))
([895367e](895367e))


### Miscellaneous

* **deps:** bump github.com/go-jose/go-jose/v4 from 4.1.4 to 4.1.6
([#7545](#7545))
([35ee952](35ee952))
* export only the +Inf bucket for limiter timers
([#7570](#7570))
([4429472](4429472))
* **router:** add drainReason label to pipeline_processed_events
([#7561](#7561))
([af0aef8](af0aef8))
* sync release v1.92.0 to main branch
([#7534](#7534))
([9ab165d](9ab165d))
* **warehouse:** bump sqlconnect-go to v1.37.1
([#7575](#7575))
([acdad67](acdad67))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
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.

4 participants