Commit 085fccb
fix: prevent nil translator panic when backend schema is unsupported (#1952)
**Description**
When the ExtProc cannot create a translator for an unsupported backend
schema, `GetTranslator` returns an error. However, `rp.upstreamFilter =
u` was assigned *before* translator creation. When the response arrived,
the router's nil check (`if r.upstreamFilter != nil`) passed because `u`
existed, but `u.translator` was nil — causing a panic in
`ProcessResponseHeaders`.
This moves the `rp.upstreamFilter = u` assignment to after successful
translator creation. If `GetTranslator` fails, `upstreamFilter` stays
nil and the existing guard at `processor_impl.go:164` routes the
response to `passThroughProcessor` instead of panicking.
**Related Issues/PRs (if applicable)**
Fixes #1941
**Special notes for reviewers (if applicable)**
`rp.upstreamFilterCount++` intentionally remains before the translator
check — it tracks the number of `SetBackend` calls (including failed
ones) and is used by `onRetry()` to detect retry scenarios. This is
unchanged from the previous behavior.
Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>1 parent 331665a commit 085fccb
2 files changed
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
594 | | - | |
| 593 | + | |
595 | 594 | | |
596 | 595 | | |
597 | 596 | | |
598 | 597 | | |
599 | 598 | | |
| 599 | + | |
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
436 | 473 | | |
437 | 474 | | |
438 | 475 | | |
| |||
0 commit comments