Skip to content

[Bug]: duplicate header values through psr/http-message & psr/http-client with curl #3132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mrtus opened this issue Mar 19, 2025 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@mrtus
Copy link

mrtus commented Mar 19, 2025

Bug report

When a request is comes in from RUM, the headers x-datadog-<x> are added already on the request.
When such a request is reused & forwarded to a next service, those headers will still be there.

However, when the request is used and converted to a curl call to the next service, the datadog context values are added again, creating a comma separated header value with duplicate values.

Example:
Image

The next service then tries to parse these headers but fails and creates a new trace root.

Given that the tracing should mostly require no code changes to codebases, I would assume we shouldn't have to strip these headers ourselves to ensure a smooth tracing.

Would it be a fix to replace these header values instead of appending them?

Thanks!

PHP version

8.3

Tracer or profiler version

1.5.1

Installed extensions

No response

Output of phpinfo()

No response

Upgrading from

No response

@mrtus mrtus added the 🐛 bug Something isn't working label Mar 19, 2025
@bwoebi
Copy link
Collaborator

bwoebi commented Mar 19, 2025

What we effectively do is calling curl_setopt(CURLOPT_HTTPHEADER, array_merge($existing_headers, $injecting_headers)); right before the actual curl_(multi_)exec; so yes, it would be possible to walk through the existing passed headers and strip those away.

We will fix this for the next minor version.

Thanks for the report @mrtus!

@mrtus
Copy link
Author

mrtus commented Mar 20, 2025

Awesome, thanks @bwoebi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants