Skip to content

chore: sync release v1.75.1 to main branch - #6961

Merged
achettyiitr merged 2 commits into
masterfrom
sync-release-19122c8e5563de21a45284585998b12cab6a3bd9
May 15, 2026
Merged

achettyiitr merged 2 commits into
masterfrom
sync-release-19122c8e5563de21a45284585998b12cab6a3bd9

Conversation

@rudderstack-github-actions

Copy link
Copy Markdown
Contributor

Description

Syncing patch release v1.75.1 to main branch

↓↓ Please review and edit commit overrides before merging ↓↓

BEGIN_COMMIT_OVERRIDE
fix(batchrouter): preserve prior LastJobStatus error on drain (#6958)
END_COMMIT_OVERRIDE

achettyiitr and others added 2 commits May 15, 2026 11:28
# Description

When a job is drained in the batch router's `scheduleJobs` (job expired,
source not found, destination disabled, etc.), the `ErrorResponse`
written to `job_status` was synthesized from an empty `{}` with just
`{"reason": "<drain reason>"}`, e.g.

```json
{ "reason": "job expired" }
```

Any upstream error from the previous delivery attempt that lived on
`job.LastJobStatus.ErrorResponse` — fields like `error`, `response`,
`firstAttemptedAt` — was clobbered, so by the time a job reached status
`Aborted` with code `410` we'd lost all the context about *why* it had
been failing.

### Change

In `router/batchrouter/worker.go`, base the drained status's
`ErrorResponse` on `job.LastJobStatus.ErrorResponse` instead of
`[]byte("{}")`. `routerutils.EnhanceJSON` then merges the new `reason`
field into the existing object rather than replacing it.

```diff
-                ErrorResponse: routerutils.EnhanceJSON([]byte(`{}`), "reason", finalReason),
+                errResponse := routerutils.EnhanceJSON(job.LastJobStatus.ErrorResponse, "reason", finalReason)
+                ErrorResponse: errResponse,
```

After the fix, a drained job's `ErrorResponse` carries the prior
upstream context alongside the drain reason:

```json
{
  "error": "500 internal server error",
  "response": "upstream timed out",
  "firstAttemptedAt": "2024-01-01T00:00:00.000Z",
  "reason": "job expired"
}
```

`ErrorCode` stays `410` and `JobState` stays `Aborted` — no change to
drain semantics, only what we surface to debuggers and downstream
reporting.

### Tests

New file `router/batchrouter/worker_test.go` with
`TestScheduleJobsDrainBranch` covering three cases against a real
`scheduleJobs` call (mocked `jobsDB`, fake drainer):

1. **`preserves prior LastJobStatus error fields and stamps the drain
reason`** — the bug-fix path. A job with a prior
`{"error":"…","response":"…","firstAttemptedAt":"…"}` is drained;
asserts all three fields survive and `reason` is stamped on top.
2. **`synthesizes reason when LastJobStatus has no prior error
response`** — first-attempt jobs (empty `LastJobStatus.ErrorResponse`)
still end up with `{"reason":"job expired"}`. No regression on the
existing behavior.
3. **`uses source_not_found reason when the job's source is missing from
the destination`** — the second branch of the same drain condition
(`!sourceFound`) also benefits from the fix; the prior error is
preserved alongside `reason: "source_not_found"`.

## Linear Ticket

- Resolves INT-6358, INT-6356, INT-6349.

## Security

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

---------

Co-authored-by: Akash <[email protected]>
🤖 I have created a release *beep* *boop*
---


##
[1.75.1](v1.75.0...v1.75.1)
(2026-05-15)


### Bug Fixes

* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([eaabb87](eaabb87))

---
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>
@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.68%. Comparing base (369f730) to head (19122c8).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6961      +/-   ##
==========================================
- Coverage   80.14%   79.68%   -0.46%     
==========================================
  Files         565      565              
  Lines       63671    63672       +1     
==========================================
- Hits        51026    50740     -286     
- Misses       9635     9931     +296     
+ Partials     3010     3001       -9     

☔ View full report in Codecov by Sentry.
📢 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.

@achettyiitr
achettyiitr merged commit 193f797 into master May 15, 2026
130 of 132 checks passed
@achettyiitr
achettyiitr deleted the sync-release-19122c8e5563de21a45284585998b12cab6a3bd9 branch May 15, 2026 08:01
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