ronething opened a new issue, #12976: URL: https://github.com/apache/apisix/issues/12976
### Current Behavior When `opentelemetry` metadata `trace_id_source` is set to `x-request-id` and the `request-id` plugin is enabled (default UUID), requests with `X-Request-Id` present trigger a Lua runtime error. The request fails and logs show a `bad argument` error. Related issues that might be similar: - #11969 - #10389 ### Expected Behavior The plugin should validate that `x-request-id` is a 32-hex trace_id (16 bytes). If invalid (UUID with hyphens, ksuid/nanoid/range_id, empty string, etc.), it should fall back to random trace_id or ignore the header. It should never crash. We can also consider supporting the generation of a valid trace ID in the `request-id` plugin. ### Error Logs 2025-02-14 14:10:24 2025/02/14 14:10:24 [error] 53#53: *537 lua entry thread aborted: runtime error: bad argument #1 to '?' (invalid value) 2025-02-14 14:10:24 stack traceback: 2025-02-14 14:10:24 coroutine 0: 2025-02-14 14:10:24 [C]: in function 'gsub' 2025-02-14 14:10:24 ...s/share/lua/5.1/opentelemetry/trace/exporter/encoder.lua:22: in function 'hex2bytes' 2025-02-14 14:10:24 ...s/share/lua/5.1/opentelemetry/trace/exporter/encoder.lua:66: in function 'for_otlp' 2025-02-14 14:10:24 ...deps/share/lua/5.1/opentelemetry/trace/exporter/otlp.lua:102: in function 'export_spans' 2025-02-14 14:10:24 ...are/lua/5.1/opentelemetry/trace/batch_span_processor.lua:45: in function 'process_batches' 2025-02-14 14:10:24 ...are/lua/5.1/opentelemetry/trace/batch_span_processor.lua:77: in function ### Steps to Reproduce 1. Enable the `request-id` plugin (default header `X-Request-Id`, algorithm `uuid`). 2. Set `opentelemetry` plugin metadata `trace_id_source` to `x-request-id`. 3. Send a request with `X-Request-Id: 123e4567-e89b-12d3-a456-426614174000`. 4. Observe the runtime error and failed request. ### Environment - APISIX version (run `apisix version`): - Operating system (run `uname -a`): - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): - APISIX Dashboard version, if relevant: - Plugin runner version, for issues related to plugin runners: - LuaRocks version, for installation issues (run `luarocks --version`): -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
