Skip to content
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

feat: Improve urlencoding logic + bug fixes #4338

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

anticorrelator
Copy link
Contributor

@anticorrelator anticorrelator commented Aug 23, 2024

  • If a HEADER that's passed using PHOENIX_CLIENT_HEADERS environment variable is not URL encoded, we will attempt to URL encode the header along while also printing a warning message. This PR mangles the header values, in case sensitive information such as authorization tokens are included in them.
  • Furthermore, this PR fixes a bug where headers were not always properly being piped through when using the GRPC SpanExporter

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 23, 2024
@@ -227,7 +227,7 @@ def __init__(self, *args: Any, **kwargs: Any):
if bound_args.arguments.get("endpoint") is None:
_, endpoint = _normalized_endpoint(None)
bound_args.arguments["endpoint"] = endpoint
super().__init__(*args, **kwargs)
super().__init__(**bound_args.arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I know the difference. lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This didnt pipe in the headers if a user set them for our GRPCExporter :(

Comment on lines +62 to +74
name, value = parts
encoded_header = f"{urllib.parse.quote(name)}={urllib.parse.quote(value)}"
match = _HEADER_PATTERN.fullmatch(encoded_header.strip())
if not match:
_logger.warning(
"Header format invalid! Header values in environment variables must be "
"URL encoded: %s",
header,
f"{name}: ****",
)
continue
_logger.warning(
f"Header values in environment variables should be URL encoded, ``{header}`` "
f"was urlencoded to: ``{encoded_header}``"
"Header values in environment variables should be URL encoded, attempting to "
"URL encode header: {name}: ****"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I know what's being fixed here. Can you update the description?

@anticorrelator anticorrelator merged commit 604fcef into main Aug 23, 2024
11 checks passed
@anticorrelator anticorrelator deleted the dustin/improve-urlencoding-logic branch August 23, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants