Skip to content

fix(ai-proxy-multi): reject instances that share a name - #13851

Merged
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:fix/ai-proxy-multi-unique-instance-name
Aug 20, 2026
Merged

fix(ai-proxy-multi): reject instances that share a name#13851
nic-6443 merged 1 commit into
apache:masterfrom
nic-6443:fix/ai-proxy-multi-unique-instance-name

Conversation

@nic-6443

Copy link
Copy Markdown
Member

ai-proxy-multi lets two instances carry the same name, but the runtime treats instance.name as the instance identity. It keys the balancer nodes (up_nodes[priority][name]), the health checker (checkers[name]) and the health status (status[name]) — none of which include the priority — so instances sharing a name collapse into one logical node with one checker.

The result is that one instance's health decides the other's fate: with several instances pointing at the same endpoint but different API keys (a common multi-key setup), a single bad key marks the shared node unhealthy and takes the working keys down with it, while requests that do go out use the first matching instance's auth. Lookups by name return the first match, so which config is used and which one is health-checked can disagree.

The name is also how ai-rate-limiting and semantic_opts.fallback reference an instance, so a duplicate is ambiguous across the whole config surface, not just in the balancer. This rejects duplicates in check_schema:

duplicate instance name 'my-instance' at instances[1] and instances[3]

Note this makes an existing config invalid: a route whose ai-proxy-multi instances share a name is rejected on the next write and dropped on reload. That configuration is already broken at runtime in the way described above, and giving distinct names is the fix users apply anyway, but it is a behaviour change on upgrade.

Tests cover the rejection and that distinct names still pass.

instance.name is the only identifier the runtime has for an instance: it
keys the balancer nodes, the health checker and the health status, none
of which include the priority. Two instances sharing a name therefore
collapse into a single logical node with a single checker, so one
instance's health decides the other's fate while requests keep using the
first instance's auth -- a config with one bad API key can take the
healthy instances down with it.

Reject duplicate names in check_schema instead of routing on that
ambiguity. The name is also how other plugins (ai-rate-limiting) and
semantic_opts.fallback reference an instance, so a duplicate is
ambiguous throughout the config surface, not only in the balancer.
Copilot AI lite review requested due to automatic review settings August 19, 2026 13:56
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 19, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dosubot dosubot Bot added the bug Something isn't working label Aug 19, 2026

@membphis membphis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@nic-6443
nic-6443 merged commit d069213 into apache:master Aug 20, 2026
20 of 28 checks passed
@nic-6443
nic-6443 deleted the fix/ai-proxy-multi-unique-instance-name branch August 20, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants