Skip to content

test(etcd): pin ProviderKey loader behavior for adapter-family payloads - #362

Merged
moonming merged 1 commit into
mainfrom
test/loader-adapter-family-schema
May 21, 2026
Merged

test(etcd): pin ProviderKey loader behavior for adapter-family payloads#362
moonming merged 1 commit into
mainfrom
test/loader-adapter-family-schema

Conversation

@moonming

Copy link
Copy Markdown
Member

Summary

Adds 4 unit tests in crates/aisix-etcd/src/loader.rs::tests covering the ProviderKey loader path that was previously unverified:

Test Asserts
provider_key_happy_path_accepts Minimal valid pk shape loads cleanly
..._aws_region_payload_currently_rejected Adapter-family bedrock payload rejected today (deny_unknown_fields)
..._gcp_project_payload_currently_rejected Same gap for vertex
..._azure_resource_payload_currently_rejected Same gap for azure

100 LOC added, single file (existing test module extended).

Why

The audit on api7/AISIX-Cloud#398 flagged Adapter family bridges (Bedrock/Vertex/Azure, ~4986 lines of Rust) as zero-signal. This PR shows one of the underlying causes: even if someone wrote a Bedrock e2e tomorrow, the provider_key row carrying aws_region would be rejected by the loader at DP boot time#[serde(deny_unknown_fields)] on ProviderKey plus the absence of aws_region / gcp_project / azure_resource_name fields means the row never reaches the snapshot.

The three rejection tests pin the current behavior so when the product fix lands (filed as #361) the tests will fail with accepted=1 instead of schema_rejected=1 — that failure is the signal to flip the assertion + drop the _currently_rejected suffix.

Test plan

  • cargo test -p aisix-etcd --lib loader:: passes locally (16/16 including the 4 new ones)

Tracking

api7/AISIX-Cloud#398 (Tier 3 MEDIUM "Pre-Patch #4 DP loader schema check")
#361 (the product fix that will make these tests evolve)

Adds 4 unit tests in crates/aisix-etcd/src/loader.rs::tests:

  ✓ provider_key_happy_path_accepts — minimal valid pk shape
    loads (the existing loader tests only covered Model + ApiKey
    happy paths; provider_keys branch at L175 was unverified).

  Three "documents current gap" tests for adapter-family extra
  config that today fails to parse via `#[serde(deny_unknown_fields)]`
  on ProviderKey:

  ✓ provider_key_aws_region_payload_currently_rejected — bedrock
  ✓ provider_key_gcp_project_payload_currently_rejected — vertex
  ✓ provider_key_azure_resource_payload_currently_rejected — azure

Each rejection test pins `stats.schema_rejected == 1`, so when
the ProviderKey struct gains adapter-family fields (or an
`adapter_config` escape hatch), each test will fail with
`accepted=1` instead of `schema_rejected=1`. That failure is the
correct signal — flip the assertion + drop the
`_currently_rejected` suffix in the same PR that adds the fields.

Filed the schema gap as #361. This unit-test PR
documents the contract; the product fix is tracked separately.

Tracking: api7/AISIX-Cloud#398 (Tier 3 MEDIUM "Pre-Patch #4 DP
loader schema check"), #361 (the actual struct fix).
Copilot AI review requested due to automatic review settings May 21, 2026 09:01
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@moonming has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 1 second before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 94f188ad-1ff4-41f8-952e-ee1753d2d75c

📥 Commits

Reviewing files that changed from the base of the PR and between 5db8503 and e403b9d.

📒 Files selected for processing (1)
  • crates/aisix-etcd/src/loader.rs

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

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

@moonming
moonming merged commit 8d68d31 into main May 21, 2026
5 of 7 checks passed
@moonming
moonming deleted the test/loader-adapter-family-schema branch May 21, 2026 09:01

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

Adds targeted unit-test coverage in aisix-etcd for the provider_keys loader path, specifically pinning current acceptance/rejection behavior when ProviderKey payloads include adapter-family configuration fields (Bedrock/Vertex/Azure) that are not yet supported by the DP loader schema.

Changes:

  • Added a happy-path unit test confirming a minimal valid ProviderKey payload is accepted and inserted into the snapshot.
  • Added three unit tests asserting that ProviderKey payloads containing aws_region, gcp_project/gcp_region, and azure_resource_name/api_version are currently schema-rejected (documenting the known gap to be fixed in #361).

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

Comment on lines +463 to +469
// adapter_map.yaml:30, but the ProviderKey struct in
// `aisix-core::models::provider_key` is
// `#[serde(deny_unknown_fields)]` and has no `aws_region`
// field. Today the loader REJECTS the entry, so a customer
// creating a Bedrock provider_key via cp-api never sees
// the row reach the DP. Tracked as a follow-up to Adapter
// family e2e coverage (Tier 3 + Tier 4-7 in #398).
Comment on lines +435 to +437
// `provider_keys` branch at L175 was unverified for either
// happy-path acceptance or for Adapter family extra-config
// rejection (the gap the audit on #398 originally flagged).
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