This is an automated email from the ASF dual-hosted git repository.
shreemaan-abhishek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new de5cbb476 fix(opentelemetry): use oneOf for metadata
additionalProperties value type (#13690)
de5cbb476 is described below
commit de5cbb476f594d3b525a088a2f285e9a2bbc583e
Author: Shreemaan Abhishek <[email protected]>
AuthorDate: Mon Jul 20 18:41:33 2026 +0800
fix(opentelemetry): use oneOf for metadata additionalProperties value type
(#13690)
---
apisix/plugins/opentelemetry.lua | 6 ++++--
t/plugin/opentelemetry.t | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/apisix/plugins/opentelemetry.lua b/apisix/plugins/opentelemetry.lua
index cecf8ba84..f1ebeea5b 100644
--- a/apisix/plugins/opentelemetry.lua
+++ b/apisix/plugins/opentelemetry.lua
@@ -93,7 +93,9 @@ local metadata_schema = {
resource = {
type = "object",
description = "additional resource",
- additionalProperties = {{type = "boolean"}, {type = "number"},
{type = "string"}},
+ additionalProperties = {
+ oneOf = {{type = "boolean"}, {type = "number"}, {type =
"string"}},
+ },
},
collector = {
type = "object",
@@ -105,7 +107,7 @@ local metadata_schema = {
type = "object",
description = "http headers",
additionalProperties = {
- one_of = {{type = "boolean"},{type = "number"}, {type
= "string"}},
+ oneOf = {{type = "boolean"}, {type = "number"}, {type
= "string"}},
},
}
},
diff --git a/t/plugin/opentelemetry.t b/t/plugin/opentelemetry.t
index 0e2687392..8d8bd049d 100644
--- a/t/plugin/opentelemetry.t
+++ b/t/plugin/opentelemetry.t
@@ -979,3 +979,39 @@ opentracing
tail -n 1 ci/pod/otelcol-contrib/data-otlp.json
--- response_body eval
qr/"traceId"\s*:\s*"(?!550e8400e29b41d4a716446655440000)[0-9a-f]{32}"/
+
+
+
+=== TEST 49: metadata_schema rejects non-scalar resource and
collector.request_headers values
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local cases = {
+ {name = "object resource value",
+ body = [[{"resource":{"service.name":{"nested":"table"}}}]]},
+ {name = "array resource value",
+ body = [[{"resource":{"service.name":["a","b"]}}]]},
+ {name = "object request_headers value",
+ body =
[[{"collector":{"address":"127.0.0.1:4318","request_headers":{"Authorization":{"a":1}}}}]]},
+ }
+ for _, case in ipairs(cases) do
+ local code = t('/apisix/admin/plugin_metadata/opentelemetry',
+ ngx.HTTP_PUT, case.body)
+ if code ~= 400 then
+ ngx.say(case.name, ": expected 400, got ", code)
+ return
+ end
+ end
+
+ -- scalars stay valid
+ local code = t('/apisix/admin/plugin_metadata/opentelemetry',
ngx.HTTP_PUT,
+
[[{"resource":{"service.name":"APISIX","weight":1.5,"debug":true},]] ..
+
[["collector":{"address":"127.0.0.1:4318","request_headers":{"Authorization":"token"}}}]])
+ if code >= 300 then
+ ngx.say("valid metadata rejected, got ", code)
+ return
+ end
+ ngx.say("passed")
+ }
+ }