Skip to content

fix(config): make every sequence field reachable from the environment - #912

Merged
jarvis9443 merged 1 commit into
mainfrom
fix/config-real-ip-trusted-proxies-env
Aug 7, 2026
Merged

fix(config): make every sequence field reachable from the environment#912
jarvis9443 merged 1 commit into
mainfrom
fix/config-real-ip-trusted-proxies-env

Conversation

@jarvis9443

Copy link
Copy Markdown
Contributor

proxy.real_ip.trusted_proxies and observability.metrics.client_type_rules could not be set through AISIX_* env vars at all. Neither falls back to its default when the env var is present — the whole config load fails:

AISIX_PROXY__REAL_IP__TRUSTED_PROXIES=10.0.0.0/8
  -> Error: config load failed: failed to load configuration:
     deserialize: invalid type: string "10.0.0.0/8", expected a sequence

The chart and the Dashboard's docker run snippet configure the gateway purely through env vars, so both fields were unreachable in the deployments we ship. That is most visible on trusted_proxies: without it the gateway logs the immediate TCP peer, so behind an ingress every request — including the caller address now carried on authentication denials — reads as the load balancer.

Implementation

Two mechanisms cover the two shapes, and every sequence field needs one of them:

  • Vec<String> / Vec<f64> — a with_list_parse_key registration, which comma-splits the value. Added for proxy.real_ip.trusted_proxies.
  • Vec<Struct> — comma-splitting cannot express it, so the field takes one JSON array through deserialize_seq_or_json_string. That was a url_rewrites private helper; it is generalized here and applied to client_type_rules too.

Auditing the whole class, those two were the only sequence fields left uncovered.

Tests

The existing YAML-scalar tests do not reach this: they exercise the deserializer, not the Environment source's list-parse registration, which is the layer that was missing. env_only_deployments_can_set_every_sequence_field loads with no config file at all and asserts all five sequence fields arrive, re-executing the test binary as a child process so env mutation stays isolated (the pattern the managed-bootstrap test already uses). It fails on both fields before this change.

config.example.yaml now shows the env spelling for both.

🤖 Generated with Claude Code

`proxy.real_ip.trusted_proxies` and `observability.metrics.client_type_rules`
could not be set through `AISIX_*` env vars at all. Neither falls back to its
default when the env var is present — the whole config load fails:

    AISIX_PROXY__REAL_IP__TRUSTED_PROXIES=10.0.0.0/8
      -> deserialize: invalid type: string "10.0.0.0/8", expected a sequence

The chart and the Dashboard's `docker run` snippet configure the gateway purely
through env vars, so both fields were unreachable in the deployments we ship.
That is most visible on `trusted_proxies`: without it the gateway logs the
immediate TCP peer, so behind an ingress every request — including the caller
address now carried on authentication denials — reads as the load balancer.

Two mechanisms cover the two shapes, and every sequence field needs one of them:

- `Vec<String>` / `Vec<f64>`: a `with_list_parse_key` registration, which
  comma-splits the value. Added for `proxy.real_ip.trusted_proxies`.
- `Vec<Struct>`: comma-splitting cannot express it, so the field takes one JSON
  array through `deserialize_seq_or_json_string` — until now a `url_rewrites`
  private helper, generalized here and applied to `client_type_rules` too.

The existing YAML-scalar tests did not catch this: they exercise the
deserializer, not the `Environment` source's list-parse registration.
`env_only_deployments_can_set_every_sequence_field` loads with no config file at
all and asserts all five sequence fields arrive, which is the shape that was
untested. It fails on both fields before this change.

`config.example.yaml` now shows the env spelling for both.
Copilot AI balanced review requested due to automatic review settings August 7, 2026 14:07
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8bddb4ed-0dad-4391-b978-d434bc9a550b

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3bd3e and f7999d2.

📒 Files selected for processing (2)
  • config.example.yaml
  • crates/aisix-core/src/config.rs

Comment @coderabbitai help to get the list of available commands.

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.

Pull request overview

Makes sequence-valued configuration fields usable through AISIX_* environment variables.

Changes:

  • Adds comma parsing for trusted proxy CIDRs.
  • Adds JSON-array parsing for structured client-type rules.
  • Adds env-only configuration coverage and examples.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/aisix-core/src/config.rs Implements sequence parsing and tests env-only loading.
config.example.yaml Documents environment variable formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.list_separator(",")
.with_list_parse_key("etcd.endpoints")
.with_list_parse_key("admin.admin_keys")
.with_list_parse_key("proxy.real_ip.trusted_proxies")
@jarvis9443
jarvis9443 merged commit 35a71b5 into main Aug 7, 2026
13 checks passed
@jarvis9443
jarvis9443 deleted the fix/config-real-ip-trusted-proxies-env branch August 7, 2026 14:17
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