feat(upstream): support http_400/http_401/http_402 in set_next_upstream - #120
Open
oowl wants to merge 1 commit into
Open
feat(upstream): support http_400/http_401/http_402 in set_next_upstream#120oowl wants to merge 1 commit into
oowl wants to merge 1 commit into
Conversation
Expose next_upstream masks for HTTP 400, 401 and 402 so that set_next_upstream() accepts these status codes, enabling failover on them (e.g. ai-proxy-advanced failover_criteria). Requires the matching nginx core flags NGX_HTTP_UPSTREAM_FT_HTTP_400/401/402. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expose
next_upstreammasks for HTTP 400, 401 and 402 so thatresty.kong.upstream.set_next_upstream()accepts these status codes. Previously only403/404/429were supported among 4xx, so passing e.g.http_401returned"argument #i is not a valid argument".Changes
src/ngx_http_lua_kong_module.c: exportngx_http_lua_kong_next_upstream_mask_http_400/401/402.lualib/resty/kong/upstream.lua: declare the new externs in theffi.cdefand add them tonext_upstream_table.Dependency
Requires the matching nginx core flags
NGX_HTTP_UPSTREAM_FT_HTTP_400/401/402, added on the Kong side via an OpenResty patch (nginx-1.27.1_26-upstream-next-extra-4xx.patchin kong-ee). Without the patch the module will fail to compile (undefinedNGX_HTTP_UPSTREAM_FT_HTTP_40x).Motivation
Lets
ai-proxy-advancedfailover to the next target/provider when an upstream returns 400/401/402 (e.g. expired/invalid API key → 401).🤖 Generated with Claude Code
Consumer
Used by Kong/kong-ee#19297 (ai-proxy-advanced
failover_criteriahttp_400/401/402).