Skip to content

fix(config): trim trailing slashes on intake urls#142

Merged
shreyamalpani merged 2 commits into
mainfrom
shreya.malpani/dd-url-config-parsing-fix
Jul 7, 2026
Merged

fix(config): trim trailing slashes on intake urls#142
shreyamalpani merged 2 commits into
mainfrom
shreya.malpani/dd-url-config-parsing-fix

Conversation

@shreyamalpani

@shreyamalpani shreyamalpani commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Trims trailing slashes from DD_URL, DD_DD_URL, and DD_APM_DD_URL and DD_LOGS_CONFIG_LOGS_DD_URL in ConfigBuilder::build() before they're used downstream. A trailing slash on DD_DD_URL/DD_URL caused DdDdUrl::new()/DdUrl::new() (from the dogstatsd crate) to reject the URL with a UrlPrefixError, causing the extension to panic and crash on startup. Also, previously, a trailing slash on DD_APM_DD_URL would produce a double slash in the resulting intake URL because the suffix /api/v0.2/traces is 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.

@shreyamalpani shreyamalpani changed the title trim trailing slashes on intake urls fix(config): trim trailing slashes on intake urls Jul 7, 2026
@shreyamalpani shreyamalpani marked this pull request as ready for review July 7, 2026 13:07
Copilot AI review requested due to automatic review settings July 7, 2026 13:07
@shreyamalpani shreyamalpani requested review from a team as code owners July 7, 2026 13:07
@shreyamalpani shreyamalpani requested review from apiarian-datadog and duncanista and removed request for a team July 7, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_url and url during 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, and DD_APM_DD_URL.

Comment thread crates/datadog-agent-config/src/lib.rs
Comment thread crates/datadog-agent-config/src/lib.rs
@shreyamalpani shreyamalpani merged commit 65eb3d0 into main Jul 7, 2026
27 checks passed
@shreyamalpani shreyamalpani deleted the shreya.malpani/dd-url-config-parsing-fix branch July 7, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants