Skip to content

fix: Sanatize HTTP client spans #690

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

Merged
merged 4 commits into from
Feb 14, 2023
Merged

Conversation

cleptric
Copy link
Member

@cleptric cleptric self-assigned this Jan 31, 2023
@cleptric cleptric requested a review from stayallive January 31, 2023 17:41
@cleptric cleptric added this to the 4.5.1 milestone Jan 31, 2023
private function formatUri(Uri $uri): string
{
// Instead of relying on Uri::__toString, we only use a sub set of the URI
return Uri::composeComponents($uri->getScheme(), $uri->getHost(), $uri->getPath(), null, null);
Copy link
Member Author

Choose a reason for hiding this comment

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

The signature is Uri::composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment), so I feel like this was implemented in a wrong way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since it's almost an internal method I think they chose not to bother with default arguments. It's also not part of the PSR-7 spec: https://www.php-fig.org/psr/psr-7/.

@cleptric cleptric modified the milestones: 4.5.1, 4.6.0 Feb 3, 2023
Comment on lines 55 to 60
$partialUri = Uri::fromParts([
'scheme' => $uri->getScheme(),
'host' => $uri->getHost(),
'port' => $uri->getPort(),
'path' => $uri->getPath(),
]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

CS seems off here:

Suggested change
$partialUri = Uri::fromParts([
'scheme' => $uri->getScheme(),
'host' => $uri->getHost(),
'port' => $uri->getPort(),
'path' => $uri->getPath(),
]);
$partialUri = Uri::fromParts([
'scheme' => $uri->getScheme(),
'host' => $uri->getHost(),
'port' => $uri->getPort(),
'path' => $uri->getPath(),
]);

And:

l: The only "worry" I have here is that a MalformedUriException is thrown for some reason. Although this might be totally unfounded since a URI was already there but maybe we want to try/catch anyway just to be 100% sure since not all PSR-7's might be created equal.

private function formatUri(Uri $uri): string
{
// Instead of relying on Uri::__toString, we only use a sub set of the URI
return Uri::composeComponents($uri->getScheme(), $uri->getHost(), $uri->getPath(), null, null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since it's almost an internal method I think they chose not to bother with default arguments. It's also not part of the PSR-7 spec: https://www.php-fig.org/psr/psr-7/.

@cleptric cleptric changed the base branch from master to develop February 14, 2023 15:40
@cleptric cleptric merged commit f788b2a into develop Feb 14, 2023
@cleptric cleptric deleted the sanatize-http-client-spans branch February 14, 2023 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants