Skip to content

fix(ai-proxy): correct logging schema key in ai-proxy-multi#12795

Merged
Baoyuantop merged 5 commits into
apache:masterfrom
yixianOu:fix/#12671
Dec 18, 2025
Merged

fix(ai-proxy): correct logging schema key in ai-proxy-multi#12795
Baoyuantop merged 5 commits into
apache:masterfrom
yixianOu:fix/#12671

Conversation

@yixianOu

@yixianOu yixianOu commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

Description

This PR unifies the schema definition in the ai-proxy-multi plugin. Previously, the ai_proxy_multi_schema used logging_schema as the key name, which was inconsistent with the ai-proxy plugin (which uses logging). This change ensures the logging configuration key is consistent across AI proxy plugins.

Checklist

  • I have unified the schema key.

Related Issue

Fixes #12671

Signed-off-by: Orician [email protected]

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Dec 6, 2025

@Baoyuantop Baoyuantop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to add additional tests to check the schema configuration in order to avoid encountering similar issues again.

@yixianOu

yixianOu commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author
Test Summary Report
-------------------
t/plugin/mcp-bridge.t        (Wstat: 0 Tests: 10 Failed: 3)
  Failed tests:  7-9
  Parse errors: No plan found in TAP output
Files=5, Tests=182, 56 wallclock secs ( 0.04 usr  0.01 sys +  4.80 cusr  2.30 csys =  7.15 CPU)
Result: FAIL

I don't know why the mcp-bridge test failed, it should have nothing to do with my modification.

@Baoyuantop

Copy link
Copy Markdown
Contributor
Test Summary Report
-------------------
t/plugin/mcp-bridge.t        (Wstat: 0 Tests: 10 Failed: 3)
  Failed tests:  7-9
  Parse errors: No plan found in TAP output
Files=5, Tests=182, 56 wallclock secs ( 0.04 usr  0.01 sys +  4.80 cusr  2.30 csys =  7.15 CPU)
Result: FAIL

I don't know why the mcp-bridge test failed, it should have nothing to do with my modification.

Ignoring this test for now, the same issue exists in other PRs.

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Dec 10, 2025
@Baoyuantop

Copy link
Copy Markdown
Contributor

We need to add additional tests to check the schema configuration in order to avoid encountering similar issues again.

Hi @yixianOu, could you add a simple test case?

@yixianOu

Copy link
Copy Markdown
Contributor Author

We need to add additional tests to check the schema configuration in order to avoid encountering similar issues again.

Hi @yixianOu, could you add a simple test case?

ok

…expect unknown logging_schema to be ignored (ok:ok). Also remove error.log requirement in schema test to match validator behavior.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Dec 13, 2025
@yixianOu

Copy link
Copy Markdown
Contributor Author

add additional tests to check the schema configuration

Comment thread t/plugin/ai-proxy.t Outdated

-- APISIX schema allows additional properties unless explicitly disallowed.
-- So unknown field 'logging_schema' should be ignored and still pass.
ngx.say((ok1 and "ok" or ("bad:" .. (err1 or ""))), ":", (ok2 and "ok" or "invalid"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is too complicated. Please use if else statements for easier code understanding.

Comment thread t/plugin/ai-proxy-multi.t Outdated

__DATA__

=== TEST 0: schema accepts 'logging' and ignores unknown 'logging_schema'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should add it to the end of the existing test.

@Baoyuantop Baoyuantop removed wait for update wait for the author's response in this issue/PR user responded labels Dec 15, 2025
@yixianOu

yixianOu commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

https://github.com/apache/apisix/actions/runs/20191178102/job/58038560408?pr=12795
CI Test Failure Analysis :

  • Failed test: TEST 15 "add plugin with algorithm nanoid" in t/plugin/request-id.t
  • Failure cause: Duplicate IDs occurred when generating 180 nanoids concurrently, leading to test output "ids not unique" instead of the expected "true"
  • Connection to my code changes:
    • ❌ My changes didn’t affect this test. I only modified:
      • apisix/plugins/ai-proxy/schema.lua (renamed field: logging_schema → logging)
      • t/plugin/ai-proxy*.t (AI-proxy test files)
      • .gitignore
    • ✅ Neither request-id.t nor apisix/plugins/request-id.lua was modified
  • Possible root cause:
    • This is an intermittent test failure, usually caused by:
      • Duplicate randomness in the nanoid library under specific concurrent conditions
      • Timing issues due to CI environment resource limits
      • Behavior of LuaJIT’s random number generator at high concurrency
    • The issue isn’t caused by my changes but by pre-existing CI instability

  operators with if-else statements

  - Replace complicated nested ternary operators in TEST 17 with
  clear if-else blocks
  - Improve code readability and maintainability in
  t/plugin/ai-proxy.t
  - Reindex test file for proper formatting
  - All linting checks pass

Signed-off-by: Orician <[email protected]>
Comment thread t/plugin/ai-proxy.t Outdated
Comment on lines +690 to +695
local ok2, err2 = plugin.check_schema({
provider = "openai",
auth = { header = { apikey = "token" } },
options = { model = "gpt-4" },
logging_schema = { summaries = true },
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be checking for failures? Why is the test result "ok"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • Why the test was originally written this way: It verified that the valid logging field passes and that old/unknown fields (e.g., logging_schema) don’t block schema validation, since additionalProperties is allowed.
  • Why I changed it: We only care that logging passes. Removing the extra check reduces noise and decouples the test from the “allow unknown fields” behavior, keeping the test focused and stable.

https://github.com/apache/apisix/actions/runs/20239133460/job/58149992555?pr=12795
https://github.com/apache/apisix/actions/runs/20239133460/job/58149992556?pr=12795
The failed CI test should have nothing to do with the code I modified

@membphis

Copy link
Copy Markdown
Member

confirmed again, this is a bug, current way is right

@Baoyuantop
Baoyuantop merged commit f271392 into apache:master Dec 18, 2025
36 of 39 checks passed
wistefan pushed a commit to wistefan/apisix that referenced this pull request Jun 16, 2026
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ai-proxy-multi-schema logging schema error

4 participants