Repository navigation
feat(router): detect and classify transformer-proxy contract breaches (INT-6839) - #7184
Conversation
3de6f6e to
8b9aacd
Compare
…stType/workspaceId tags Make the transformer-proxy delivery contract observable (INT-6839): - Emit router.transformerproxy.invalid.response with reason="unmarshal error" when the oauth TransportResponse unmarshal fails (previously discarded). - Emit reason="missing output" when the response envelope has no output field. - Add destType + workspaceId tags to the existing reason="in out mismatch" emission so the downstream alert can name the broken integration. destType is threaded into getResponse from proxyReqParams.DestName; workspaceId is sourced from the request metadata. Scanned-by: gitleaks 8.30.0
…nse metric A workspace can host multiple destinations of the same destType, so destType alone cannot pinpoint the destination breaching the delivery contract. Add a destinationId tag (camelCase, matching the sibling router_transformerproxy_request_result metric) at all three invalid.response emit sites: reason="unmarshal error" and reason="missing output" in transformer.go, and reason="in out mismatch" in transformer_proxy_adapter.go. Sourced from the proxy request metadata (Metadata[0].DestinationID), alongside the existing workspaceId. Scanned-by: gitleaks 8.30.0
… sites On-call debugs these breaches by port-forwarding and looking events up in jobsDB by jobID, so the breach logs need to carry the jobIDs (and destinationId), not the response payload. - Add a Warnn alongside the reason="unmarshal error" and reason="missing output" metric emits in transformer.go, each carrying the destination id and the batch's jobIDs (sourced from the proxy request metadata). The response body is deliberately not logged. - Add a destinationId field to the existing in-out-mismatch Warnn in transformer_proxy_adapter.go, which previously logged only the jobID slices. Scanned-by: gitleaks 8.30.0
…response metric
No consumer reads workspaceId: Alertmanager routes on namespace, the runbook
never branches on it, and the affected workspace is recoverable from jobsDB
(unionjobsdb('rt', N) returns workspace_id). It was added only for symmetry
with transformer_proxy_request_result, which does not justify carrying a
high-cardinality label nothing queries.
Drops the tag at all three emit sites; reason, destType and destinationId are
retained. The Warnn fields are deliberately left untouched -- destinationId and
the jobIDs there are load-bearing for the runbook's jobsDB lookup.
Scanned-by: gitleaks 8.30.0
f83d512 to
687e80e
Compare
shekhar-rudder
left a comment
There was a problem hiding this comment.
Automated /code-review (high effort). 1 correctness bug + 2 cleanup findings, posted inline. The PR is safe additive instrumentation overall, but finding #1 will make the alert this PR unblocks double-fire.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7184 +/- ##
==========================================
- Coverage 80.14% 80.10% -0.05%
==========================================
Files 595 599 +4
Lines 66350 66807 +457
==========================================
+ Hits 53178 53515 +337
- Misses 10031 10134 +103
- Partials 3141 3158 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Addresses review feedback on #7184. 1. Correctness. A non-JSON proxy response double-counted the metric. The `unmarshal error` branch did not return, so `output` could not exist and the `missing output` branch fired as well: one breach produced two reason-series, two logs, and two alert series on a `> 0` per-reason rule, making per-reason counts non-additive. Both branches now return a ProxyRequestResponse, so the double count is structurally impossible rather than filtered out. The status code is unchanged, so job outcomes and retry behaviour are the same; only the diagnostic body changes. It now carries the payload that explains the failure instead of the empty string the old path produced - three tests were asserting that empty `respData: `, which was the bug itself. 2. Cleanup. The three emit sites collapse into one `emitProxyInvalidResponse` helper with a single tag set, and `proxyJobIDs` replaces the copy-pasted lo.Map closure. A fourth reason is now one call, not another ten-line copy. 3. Testability. The adapter no longer writes this metric through the global `stats.Default`. It reports the jobID mismatch on TransResponse, and ProxyRequest records it via `trans.stats`, so all three reasons share one handle and are visible to a stats handle injected on the transformer handle. Because the emit moved out of the adapter, the `destType` parameter that was threaded into `getResponse` is no longer needed, so that signature change is reverted across the interface, both adapters, and their tests. The adapter test that asserted a warning log now asserts the returned mismatch instead, which is the adapter's actual contract. Scanned-by: gitleaks 8.30.0
Addresses review feedback on #7184. The error-path ProxyRequestResponse literal - same six fields, with only the status code and body varying - was built at seven sites in ProxyRequest. They now go through proxyErrorResponse(code, body, dontBatch), so a change to the error-response shape is one edit instead of seven with a drift risk. RespStatusCodes/RespBodys are empty literals inside the helper rather than parameters. routerJobResponseCodes and routerJobResponseBodys were declared in ProxyRequest and never written on any path - the writes near the end target transResp's maps, not these - so every error site was passing an empty map. With the literals inlined, both locals became dead and are removed. The success return is deliberately left as a literal: it has a different content type, carries OAuthErrorCategory, and returns the adapter's populated maps, so folding it in would mean parameterising away the thing that makes it different. Written as a plain function rather than a method on the handle, matching proxyJobIDs and emitProxyInvalidResponse, since it does not use the receiver. Scanned-by: gitleaks 8.30.0
shekhar-rudder
left a comment
There was a problem hiding this comment.
Automated /code-review (high effort). Found 3 correctness issues (2 confirmed, 1 plausible) + 1 minor cleanup. All are about what now trips the metric — which matters because the downstream proxy-invalid-response alert fires at > 0. The refactor itself (proxyErrorResponse, the stats.Default→trans.stats move, v0 leaving jobIDMismatch zero-valued) is correct. Not flagging the destinationId cardinality or missing workspaceId — both are deliberate, documented decisions in the PR description.
Addresses review feedback on #7184. httpResponseCreator fabricates an *http.Response whose body is a plain-text error string produced by this transport, not a payload received from the upstream service. Callers had no way to tell the two apart, so a transport failure was indistinguishable from an upstream that returned a malformed body. Set X-Rudder-Oauth-Transport-Error on every such response. The marker goes on the single constructor rather than at the call sites, so all eight synthetic responses carry it and a ninth added later gets it for free. Scanned-by: gitleaks 8.30.0
…-6839) Addresses review feedback on #7184. Transport errors are no longer reported as contract breaches. A response carrying X-Rudder-Oauth-Transport-Error was synthesized by the oauth transport and its body is a plain-text error, so unmarshalling it always fails. That was being attributed to the transformer as "unmarshal error", which would have made the new alert fire on our own network faults. Such responses now emit reason="transport error" instead, keeping the transformer-contract reasons clean. A regression test asserts the reason on that path. An explicit JSON null output is now treated as missing. gjson's Exists() returns true for a literal null because its Raw is non-empty, so {"output": null} reached getResponse and failed later with a less specific error rather than being reported as the contract breach it is. JobIDs are deduped before the in/out mismatch check. A batch can legitimately carry the same JobID more than once - router/worker.go dedupes the same way before building responses - while the transformer returns one entry per job, so metadata [11,11,21] against response [11,21] was a spurious mismatch, and would now be a spuriously alerted one. emitProxyInvalidResponse takes proxyReqParams rather than the destType and destinationId strings, so the two cannot be transposed at a call site and silently mis-tag the metric that routes the page. The proxy test cases gained expectedBreachReason, asserting that one breach produces exactly one metric under exactly one reason. Scanned-by: gitleaks 8.30.0
Addresses review feedback on #7184. The previous commit deduped jobIDsInMetadata but not jobIDsInResponse, which made the comparison sensitive to something neither side guarantees. worker.go sends every metadata entry to the transformer, deduping only when it builds the final job responses, so a repeated JobID is a real input; the transformer is free to collapse those duplicates or echo one entry per item. With one-sided dedup, metadata [11,11,21] against an echoed response [11,11,21] compared as [11,21] vs [11,11,21] and reported a mismatch the old un-deduped code did not. Both sides now go through lo.Uniq, so the check answers the question it is meant to - did the transformer return results for the same set of jobs we sent - rather than depending on how it handles duplicates. Covers both transformer behaviours with a table test; the echo case fails without the second lo.Uniq. Scanned-by: gitleaks 8.30.0
…NT-6839) Addresses review feedback on #7184. The mismatch check moves out of the adapter and into ProxyRequest, next to the other two breach reasons (unmarshal error, missing output). TransResponse loses jobIDMismatch, jobIDsInMetadata and jobIDsInResponse - three fields that were carried on every proxy response to serve a rare log line - and the adapter no longer imports lo, slices or reflect. Its contract shrinks to "parse the response into the maps". The caller derives the response jobID set from the keys of routerJobResponseCodes, which is keyed by the jobIDs the transformer answered for, and compares it against the deduped request jobIDs with slices.Equal. This also removes the class of bug from the previous round for good: the response side comes from map keys, which are inherently unique, so there is no second slice that can be left un-deduped and no way for a duplicate-jobID batch to page by accident. Behaviour is unchanged for both versions. v1 keys the map by response jobIDs, so the keys are the response set; v0 keys it by request jobIDs, so the sets are always equal and it never mismatches, as before. Tests follow the logic: the adapter tests now assert the response map is keyed by the deduped jobID set (the load-bearing invariant), and a new ProxyRequest case asserts that a transformer answering for a different set of jobs than were sent pages with reason "in out mismatch". Scanned-by: gitleaks 8.30.0
… breach (INT-6839)
Follow-up hardening from a review of this PR's own classification.
The transport-error reason only covered responses the oauth transport
synthesizes itself (httpResponseCreator). The common real infra failure - the
transformer/LB/gateway returning an HTTP 5xx with a body - is a valid HTTP
response (err == nil) that carries no marker header, so it was reaching the
content classifier and paging as a contract breach: "missing output" for oauth
destinations (the 5xx body is wrapped into a valid envelope by postRoundTrip,
then has no output field) and "unmarshal error" for non-oauth destinations (the
raw non-JSON body fails the outer unmarshal). Both page the contract owner on a
fleet-wide infra event - the exact false positive this reason was added to
prevent. Pre-PR these paths emitted no metric, so it was a new false page.
Classify infra up front: infraFailure is true when the transport synthesized the
response (transportError, which also covers a 4xx like a failed token fetch) OR
the upstream status is >= 500. An infra failure is reported as "transport error"
and returned before the content checks, which now only see genuine transformer
responses. This also removes the dependency on "a synthesized body is always
non-JSON": transportError is now consulted independently of unmarshal success.
Also:
- Emit "unmarshal error" on the adapter getResponse failure. A present-but-
malformed output (e.g. {"output":[1,2,3]}) was the one breach class that
incremented no metric; the sibling outer-unmarshal and missing-output paths
both emit.
- emitProxyInvalidResponse is now a *handle method (drops the threaded
stats/logger args); log the upstream statusCode on transport errors.
- Tests: the runner now asserts the exact set of breach reasons, so a healthy
response asserting none catches a spurious page, not just a mislabel. Added a
duplicate-jobID batch case (must not page) and asserted the getResponse
unmarshal-error reason. The two LB-outage cases now expect "transport error".
Scanned-by: gitleaks 8.30.0
|
Pushed a follow-up ( Gap: the
Both page the contract owner on a fleet-wide infra event - the exact false positive Fix: classify infra up front - Also in the same commit:
The two |
Matches the stdlib idiom already used in-repo, dropping a lo.Keys call and a separate slices.Sort in favor of one expression. Scanned-by: gitleaks 8.30.0
… parseable response (INT-6839) Removes a regression risk in the previous commit. That version returned early on infraFailure (upstream 5xx or transport-synthesized) before extracting output, so a 5xx response that still carried a usable output would have had its per-job results dropped and the whole batch retried - a behavior change resting on the unverified assumption that a top-level 5xx never carries a processable output. Instead, infraFailure now only picks the reason at the points where the response cannot be processed (unmarshal failure, missing output, output-unmarshal failure). A response that parses is applied exactly as before; only the metric reason changes for the failures. This is robust to the proxy protocol either way, and still classifies the real infra failures (whose bodies have no usable output) as transport error. transportError is now consulted at all three failure points, so a synthesized response with a valid-JSON body is caught too. Added a regression case: a 502 carrying a valid output applies the per-job result, preserves the 502, and does not page. It fails if the short-circuit is reintroduced. The LB-outage cases keep their original body (they flow through the missing-output path); only their reason changed to transport error. Scanned-by: gitleaks 8.30.0
shekhar-rudder
left a comment
There was a problem hiding this comment.
Reviewed against the source at d638175; built it and ran go test ./router/transformer/... (passes). Also traced ProxyRequestResponseBody consumers in router/worker.go and the proxy's status-code behaviour in rudder-transformer. Seven inline comments — two of them I'd treat as blocking, both about the new transport error reason.
…(INT-6839) Addresses review feedback on #7184. statusCode >= 500 is dropped from the infra signal. For v0 the transformer mirrors the destination's delivery status (deliveryPostProcess in rudder-transformer), so any destination 5xx comes from a healthy transformer; using it as a reason selector would relabel a genuine missing-output/unmarshal breach that co-occurs with a destination 5xx as "transport error" - the exact case this alert exists to catch, routed to the wrong runbook branch and, with the alert exclusion, not paged at all. The status is now a log field only, and infraFailure is httpPrxResp.transportError. The LB-outage cases go back to "missing output"; a fleet-wide transformer failure is handled by grouping on the alert side rather than by relabeling here. Also from the same review: - Duplicate response entries are flagged again. The deduped set comparison fixed a false positive but introduced a false negative: two entries for one jobID collapse to a single map key (last write wins), silently dropping a status. The adapter now reports responseEntries and the caller flags entries > keys as "in out mismatch". Request-side duplicates stay legitimate. - Error bodies embedding the upstream payload are truncated. Nothing reads ProxyRequestResponseBody (router/worker.go consumes only the per-job maps) and a batch response can be multi-MB. - The three infra branches get distinct log messages so a line identifies its site. - v0Adapter/v1Adapter drop the now-unread logger field and the constructor parameter. - Tests for the two untested reasons: a body with no output field, and an explicit "output":null (which pins the gjson.Null half of the guard), plus the duplicate-jobID response case. Each fails if its guard is removed. Scanned-by: gitleaks 8.30.0
…ot say Keeps the non-obvious reasoning (why the upstream status is not an infra signal, why response-side duplicates need their own check) and drops the restatement. Scanned-by: gitleaks 8.30.0
shekhar-rudder
left a comment
There was a problem hiding this comment.
Separate from the transport error classification thread (continued there) — four other things from a pass over the head ref.
-
[medium] The infra signal is upstream-controlled.
transformer.go:838-842readsresp.Header.Get(oauthv2httpclient.TransportErrorHeader)off responses that, on the non-oauth passthrough (transport.go:256) and thepostRoundTripreal-response path (transport.go:172,:210), carry the upstream's headers verbatim. Anything in front of the transformer that setsX-Rudder-Oauth-Transport-Errorsilently suppresses the breach alert. Cheap fix:res.Header.Del(TransportErrorHeader)on the genuine-response paths, or carry the flag on a wrapper type / context value rather than a header that can arrive over the wire. -
[medium] Undocumented v0 delivery-semantics change for
{"output":null}. Before this PR,respDatabecame"null",v0Adapter.getResponseunmarshalled it without error, and the loop attransformer_proxy_adapter.go:103-106assignedrespCodeto every job — so a 200 carrying a null output marked the whole batch delivered. With the new guard attransformer.go:570it returns an error response with empty maps, andhydrateRespStatusCodes(router/worker.go:815-823) turns that into 500-for-every-job plus retry.That's almost certainly the correct behaviour, but it flips previously-succeeding deliveries into retries for any destination that legitimately answers
{"output":null}, and it isn't called out in the description. The only{"output":null}case isproxyVersion: "v1"(transformer_test.go:1730) — worth adding the v0 counterpart and a line in the PR body. -
[medium] Test coverage for
transport errorexercises one of the eighthttpResponseCreatorsites.expectedBreachReason: "transport error"appears once, on theioReadErrorcase (transformer_test.go:1065), which hitstransport.go:145. The sites that matter most for keeping infra off the page —FetchTokenfailure (transport.go:118), augmentation failure (:129) andTransport.RoundTriperror (:294) — have no case pinning their reason. Given that the alert now depends entirely on that label being right, those are the ones worth pinning. -
[nit]
truncatedBody(transformer.go:436-442) slices at a byte offset, so a 10KB cut can land mid-rune and emitU+FFFDinto the error string.utf8.DecodeLastRunetrim-back, or a comment saying it's accepted.
Addresses review feedback on #7184. An upstream 5xx the transport did not synthesize - an ingress/LB error page in front of the transformer - was classifying as a contract breach and paging: "missing output" on oauth destinations, "unmarshal error" on non-oauth ones. Neither is excluded by the alert. The signal that separates these is provenance, not status: did the response come from the transformer at all. The apiVersion header answers exactly that - the transformer sets it, an ingress error page does not - so infraFailure is now transportError || !fromTransformer. A destination 5xx still carries a usable output from a healthy transformer and is unaffected, which is why status was dropped as a selector in the first place. Also from the same review: - The transport marker is stripped from any response that arrived over the wire, so only this transport can assert it. Without that, anything in front of the transformer could set X-Rudder-Oauth-Transport-Error and silence the alert. A test pins it: an upstream that sets the marker itself is still reported. - v0 counterpart of the {"output":null} case. This PR changes v0 delivery semantics there - v0 previously assigned respCode to every job, so a 200 carrying a null output marked the batch delivered, and it now fails and retries. Called out in the PR description. - transport error coverage beyond the body-read site: a case where the transformer is unreachable, pinning the RoundTrip-error path. - truncatedBody trims back off a partial rune instead of cutting mid-rune. Scanned-by: gitleaks 8.30.0
|
All four addressed in 1. Infra signal is upstream-controlled Good catch - and it is the same hole I had flagged to myself about the header being a side channel, without following it to "upstream can set it".
Test pins it: an upstream that sets 2. Undocumented v0 Right, and I had under-reported this. When I traced the delivery impact I checked the v1 path, where the maps are empty either way and Added the v0 counterpart case and called the change out in the PR description under a behaviour-change heading. Agreed it is the correct behaviour - a null output is not a delivery - but it should not have been silent. 3. Added the Not covering 4. Fixed rather than documented - |
…sport marker (INT-6839) Addresses review feedback on #7184. The X-Rudder-Oauth-Transport-Error machinery was working around a stamp that did not work. httpResponseCreator set apiVersion via a raw map literal (http.Header{"apiVersion": ...}), whose key is non-canonical, so resp.Header.Get("apiVersion") already returned "" for synthesized responses - !fromTransformer alone already classified them, and the marker header was pure redundancy. Nothing read apiVersion on those responses either: every reader gates on StatusCode == 200 and all synthesized responses are non-2xx. Made the absence intentional instead of accidental: httpResponseCreator no longer sets apiVersion, and infra is classified by !fromTransformer alone. That lets the marker header, stripTransportErrorHeader and its two call sites, the transportError field, and the spoof test all go. It also flips the residual failure mode to the safe side. Before, an upstream forging the marker would silence the breach alert; the strip existed to guard that. Now a forged apiVersion makes a genuine breach page (a false page, never a silence), so the guard is unnecessary rather than merely removed. Behaviour is unchanged: the LB-outage and unreachable-transformer cases still resolve to transport error, now via apiVersion absence. Both fail if the check is dropped. Also from the same review: - truncatedBody does a plain byte cut; a mid-rune cut is acceptable since nothing reads ProxyRequestResponseBody. Drops the buggy single-byte trim-back. - responseEntries -> responseEntriesCount (the Go identifier; the log key stays). Scanned-by: gitleaks 8.30.0
| "destType": proxyReqParams.DestName, | ||
| "destinationId": destinationID, | ||
| }).Increment() | ||
| trans.logger.Warnn(msg, append([]logger.Field{obskit.DestinationID(destinationID)}, fields...)...) |
There was a problem hiding this comment.
Do we need both a metric and a warning log? High frequency logs should be avoided if possible
There was a problem hiding this comment.
Keeping both, deliberately. These are breach paths, not steady-state - the metric has emitted nothing in prod over 90d, so this is not a high-frequency logger. And the log is load-bearing on its own: it carries the jobIDs, which is the whole triage story - the runbook pulls those and reads the affected events out of jobsDB before they age out. The metric drives the alert; the log is how you act on it. Neither replaces the other.
…h path (INT-6839) Addresses review feedback on #7184. - Emit transport error on the requestError path. A raw transport failure (unreachable transformer, timeout, 404, unreadable body) surfaces there as a Go error for non-oauth destinations and returned before emitting, so those never showed on the metric while the oauth path (which synthesizes a response) did. Now both do. Excluded from the alert, so it pages nothing. Covered by a 404 case that fails if the emit is dropped. - emitProxyInvalidResponse becomes a closure inside ProxyRequest, declared past the empty-metadata guard, so Metadata[0] is structurally safe and no destType/destinationId is threaded to a call site. - Metric name uses underscores (router_transformerproxy_invalid_response), matching every other stat in the file; dots and underscores map to the same Prometheus series. - Reasons are constants (reasonTransportError, reasonUnmarshalError, reasonMissingOutput, reasonInOutMismatch). - proxyJobIDs becomes ProxyRequestPayload.JobIDs(). - ProxyRequestParams.DestName renamed to DestType, matching the rest of rudder-server. - truncatedBody bounds at 1KB (was 10KB), still a byte-slice so a multi-MB body is never allocated. - httpResponseCreator doc explains apiVersion absence covers non-transformer errors generally (ingress/reverse proxy, unhandled transformer exceptions routed through the global error handler), not just this transport's own errors. The metric + log pairing is kept: these are rare breach paths (0/90d), and the log carries the jobIDs that the runbook uses to read the events out of jobsDB. Scanned-by: gitleaks 8.30.0
🤖 I have created a release *beep* *boop* --- ## [1.82.0-rc.1](v1.81.0...v1.82.0-rc.1) (2026-08-03) ### Features * **processor:** fork event processing for configured isolated destinations ([#7207](#7207)) ([6eb91b4](6eb91b4)) * **processor:** isolated destination processing pipeline ([#7202](#7202)) ([a684641](a684641)) * **router:** detect and classify transformer-proxy contract breaches (INT-6839) ([#7184](#7184)) ([c7a15a8](c7a15a8)) * **router:** gate 296 delivered-with-warning behind per-workspace rollout ([#7217](#7217)) ([1d772a1](1d772a1)) ### Bug Fixes * apply configured client QPS and Burst settings in restConfig ([#7220](#7220)) ([762bc06](762bc06)) * gcs manager allows non-service account credentials and warehouse ssl keys can escape their containing path ([#7227](#7227)) ([3e126b2](3e126b2)) * mid-run pod deaths under concurrent test runs ([#7212](#7212)) ([5279b64](5279b64)) * normalize null BingAds offline conversion fields ([#7236](#7236)) ([678f130](678f130)) * use correct JSON tag for adjustedConversionTime in bing-ads ([#7204](#7204)) ([50df0f7](50df0f7)) ### Miscellaneous * add new readme logo ([#7200](#7200)) ([ab86afd](ab86afd)) * **deps:** bump the go-deps group across 1 directory with 32 updates ([#7199](#7199)) ([0eaa833](0eaa833)) * **jobsdb:** graceful shutdown of addNewDSLoop and refreshDSListLoop ([#7210](#7210)) ([78e104c](78e104c)) * remove archiveInPreProcess processor toggle ([#7205](#7205)) ([f471b1d](f471b1d)) --- 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>
🤖 I have created a release *beep* *boop* --- ## [1.82.0](v1.81.0...v1.82.0) (2026-08-03) ### Features * **processor:** fork event processing for configured isolated destinations ([#7207](#7207)) ([6eb91b4](6eb91b4)) * **processor:** isolated destination processing pipeline ([#7202](#7202)) ([a684641](a684641)) * **router:** detect and classify transformer-proxy contract breaches (INT-6839) ([#7184](#7184)) ([c7a15a8](c7a15a8)) * **router:** gate 296 delivered-with-warning behind per-workspace rollout ([#7217](#7217)) ([1d772a1](1d772a1)) ### Bug Fixes * apply configured client QPS and Burst settings in restConfig ([#7220](#7220)) ([762bc06](762bc06)) * gcs manager allows non-service account credentials and warehouse ssl keys can escape their containing path ([#7227](#7227)) ([3e126b2](3e126b2)) * mid-run pod deaths under concurrent test runs ([#7212](#7212)) ([5279b64](5279b64)) * normalize null BingAds offline conversion fields ([#7236](#7236)) ([678f130](678f130)) * use correct JSON tag for adjustedConversionTime in bing-ads ([#7204](#7204)) ([50df0f7](50df0f7)) ### Miscellaneous * add new readme logo ([#7200](#7200)) ([ab86afd](ab86afd)) * **deps:** bump the go-deps group across 1 directory with 32 updates ([#7199](#7199)) ([0eaa833](0eaa833)) * **jobsdb:** graceful shutdown of addNewDSLoop and refreshDSListLoop ([#7210](#7210)) ([78e104c](78e104c)) * remove archiveInPreProcess processor toggle ([#7205](#7205)) ([f471b1d](f471b1d)) --- 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>
What
Makes the transformer-proxy delivery contract observable for INT-6839.
A contract breach is when rudder-server sends a batch of jobs to a destination's proxy endpoint and gets back a response it cannot reconcile with what it sent — per-job results end up attached to the wrong jobs, or the batch can't be read at all, and no ordinary delivery failure records it. Today
router_transformerproxy_invalid_response(Go statrouter.transformerproxy.invalid.response) is emitted for only one of those ways, carries no attribution, and has no alert.This PR emits the metric at every breach site with attribution, classifies infrastructure failures separately so they don't page as breaches, and logs the affected jobIDs so on-call can pull the real events out of jobsDB.
Reasons
reasonin out mismatchmissing outputoutputfield, or an explicit"output":nullunmarshal erroroutputpayload, would not parsetransport errorAll carry
reason,destType,destinationId, and log the upstreamstatusCode.How infra is told apart from a breach
The signal is provenance, not status: did the response actually come from the transformer? Only the transformer stamps the
apiVersionheader (ControllerUtility.deliveryPostProcess), so a response lacking it did not come from the transformer — an oauth-transport-synthesized error, an ingress/reverse-proxy error page, or an unhandled transformer exception routed through the global error handler rather thandeliveryPostProcess.doProxyRequestrecordsfromTransformerfrom the header's presence, andinfraFailure := !fromTransformerselects thetransport errorreason. No separate marker header is needed.The upstream HTTP status is deliberately not part of that signal. For v0 the transformer mirrors the destination's delivery status (
deliveryPostProcess), so any destination 5xx comes from a perfectly healthy transformer — using it would relabel a genuine breach that co-occurs with a destination 5xx as infra, which is exactly the case this exists to catch. The status is logged instead.Infra only ever selects the reason at the points where the response can't be processed; a response that parses is applied exactly as before, so a 5xx still carrying a usable output is delivered normally. A raw transport failure (unreachable transformer, timeout, 404) surfaces as a request error and is emitted as
transport errortoo, so the metric is symmetric across oauth and non-oauth destinations.The breach logs — jobIDs, not bodies
Each site logs via
WarnnwithdestinationId,jobIDs, andstatusCode. The three infra branches carry distinct messages so a log line identifies its site.The response body is deliberately not logged. These get debugged by port-forwarding jobsDB and reading the events by jobID, so the jobIDs are what the logs carry. The runbook's lookup uses rudder-server's own
unionjobsdb('rt', N)to span the rotatingrt_jobs_<n>datasets and join each job's latest status. Bodies embedded inProxyRequestResponseBodyare truncated at 10KB — nothing consumes that field (router/worker.goreads only the per-job maps) and a batch response can be multi-MB.Behaviour change:
{"output":null}is no longer a deliveryA response carrying an explicit null output is now treated as
missing outputand returned as an error, so the batch fails and retries.On v1 this matches what already happened (the per-job maps came back empty either way, and
hydrateRespStatusCodesmarked every job 500). On v0 it is a real change:v0Adapter.getResponseassignsrespCodeto every job off the request metadata, so a 200 carrying a null output previously marked the whole batch delivered. Any destination that legitimately answers{"output":null}will now see those jobs fail and retry instead.That is the intended semantics — a null output is not a delivery — but it is a change in outcome, not just in observability. Covered by tests on both versions.
Why these labels — and why not
workspaceIdreasondrives the runbook branch and the page text;destTypenames the broken integration;destinationIdpinpoints which destination is breaching (a workspace can run several destinations of one destType).workspaceIdwas added in an earlier commit and then deliberately dropped: nothing consumes it. Alertmanager routes onnamespace, the runbook never branches on it, and the affected workspace is recoverable from jobsDB —unionjobsdbreturnsworkspace_id.Notable design points from review
TransResponseno longer carries the mismatch flag or the jobID slices;ProxyRequestderives the response set frommaps.Keys(routerJobResponseCodes)and compares against the deduped request jobIDs. All reasons are detected and emitted in one place, through one stats handle.router/worker.godedupes only when building final responses), so the set comparison dedupes both sides. Response-side duplicates are not — the adapter reportsresponseEntriessoentries > keysis flagged, since the map write silently keeps the last status.{"output":null}counts as missing. gjson reports an explicit null as existing (Raw == "null"), so the type is checked too.Tests
Breach classification is asserted through a memstats store: each case pins the exact set of emitted reasons, so a healthy response asserting none catches a spurious page, not just a mislabel. Covered: all four reasons,
"output":null, a body with nooutputfield, a duplicate-jobID response, a duplicate-jobID request (must not page), and a 5xx carrying a usable output (must be applied, not dropped). Each was verified to fail when its guard is removed.Downstream / gating
Unblocks the operator alerts in rudderlabs/rudderstack-operator#1452, which split by blast radius:
in out mismatchpages per destination, the response-shape reasons page coarsely per destType, andtransport errorpages from neither.