fix(config): trim trailing slashes on intake urls#142
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens datadog-agent-config URL handling by trimming trailing slashes from configured intake URLs during ConfigBuilder::build(), preventing downstream URL parsing errors (notably UrlPrefixError from the dogstatsd crate) and avoiding double-slash paths when suffixes are appended.
Changes:
- Trim trailing slashes for
dd_urlandurlduring config build. - Trim trailing slashes before normalizing logs and APM intake URLs.
- Add unit tests covering trailing-slash inputs for
DD_LOGS_CONFIG_LOGS_DD_URL,DD_DD_URL,DD_URL, andDD_APM_DD_URL.
litianningdatadog
approved these changes
Jul 7, 2026
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Trims trailing slashes from
DD_URL,DD_DD_URL, andDD_APM_DD_URLandDD_LOGS_CONFIG_LOGS_DD_URLinConfigBuilder::build()before they're used downstream. A trailing slash onDD_DD_URL/DD_URLcausedDdDdUrl::new()/DdUrl::new()(from the dogstatsd crate) to reject the URL with aUrlPrefixError, causing the extension to panic and crash on startup. Also, previously, a trailing slash onDD_APM_DD_URLwould produce a double slash in the resulting intake URL because the suffix/api/v0.2/tracesis added to the path.Motivation
Reported in SVLS-9373: setting DD_URL/DD_DD_URL/DD_APM_DD_URL with a trailing slash produced malformed intake URLs for consumers of this crate.
Describe how to test/QA your changes
Added unit tests covering trailing-slash inputs for each affected env var. All existing tests in datadog-agent-config continue to pass.
Also tested manually with a lambda function, no longer crashes on parsing an env var url with a trailing slash.