Skip to content

config: do not echo secret URLs in YAML parse errors - #5749

Open
vignesh2027 wants to merge 1 commit into
prometheus:mainfrom
vignesh2027:fix/secret-url-yaml-errors
Open

vignesh2027 wants to merge 1 commit into
prometheus:mainfrom
vignesh2027:fix/secret-url-yaml-errors

Conversation

@vignesh2027

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Please check all the applicable boxes.

  • Please list all open issue(s) discussed with maintainers related to this change
  • Is this a new Receiver integration?
  • Is this a bugfix?
    • I have added tests that can reproduce the bug which pass with this bugfix applied
  • Is this a new feature?
    • I have added tests that test the new feature's functionality
  • Does this change affect performance?
    • I have provided benchmarks comparison that shows performance is improved or is not degraded
      • You can use benchstat to compare benchmarks
    • I have added new benchmarks if required or requested by maintainers
  • Is this a breaking change?
    • My changes do not break the existing cluster messages
    • My changes do not break the existing api
  • I have added/updated the required documentation
  • I have signed-off my commits
  • I will follow best practices for contributing to this project

When a secret URL in the YAML config does not parse, the load error quotes the whole value, so a token in the path ends up in the error and in the logs. This affects fields such as slack_api_url, slack_configs.api_url, the other webhook_url fields and webhook_configs.url.

SecretURL already redacts the value for JSON (#3884) but the YAML path went straight through URL.UnmarshalYAML. This parses in SecretURL.UnmarshalYAML and replaces errors that quote the input with invalid URL (value redacted) or unsupported scheme for URL (value redacted). SecretTemplateURL gets the same treatment for non-templated values. When secrets are marshaled in clear the original error is kept, as the JSON path does.

Example with a made-up token: parse "http://hooks.example.com/%zz/SECRETTOKEN123": invalid URL escape "%zz" becomes invalid URL (value redacted).

Tests cover the global and per receiver fields through Load, plus SecretURL and SecretTemplateURL directly.

[BUGFIX] config: Do not include secret URLs in the error returned when one fails to parse in the YAML configuration.

A secret URL that fails to parse in the YAML config used to produce an
error quoting the whole value, including any token in the path. The JSON
path already redacts it. Do the same for YAML, for SecretURL and for the
non-templated case of SecretTemplateURL, and keep the original error when
secrets are marshaled in clear.

Signed-off-by: vigneshwar <applemacbook6sep2004@gmail.com>
@vignesh2027
vignesh2027 requested a review from a team as a code owner November 17, 2026 01:49
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

URL parse errors for secret-bearing values are redacted when MarshalSecretValue is disabled. Tests cover YAML unmarshalling and configuration loading, including error behavior when secret-value marshalling is enabled.

Changes: Secret URL error redaction

Layer / File(s) Summary
Parse and validate secret URLs
config/common/url.go, config/common/url_test.go, config/config_test.go
ParseURL marks unsupported-scheme errors, and redactURLError replaces selected parse errors with fixed messages when MarshalSecretValue is disabled. SecretURL.UnmarshalYAML and SecretTemplateURL.UnmarshalYAML apply redaction to parse errors. Tests check YAML error contents and verify that configuration load errors omit the secret token.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to b51ce

This change stops secret URL tokens from appearing in YAML configuration parse errors and keeps the original error when secrets are marshaled in clear. It carries no known merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "config: do not echo secret URLs in YAML parse errors" follows the area: description form and matches the main change. The PR stops YAML parse errors for secret URL fields from quoting the f…
Description check Passed The description covers the problem, the fix, the example error change, and the test scope. It fills in the checklist items that apply and gives a release-notes entry. It links related issue #3884 unde…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "config: do not echo secret URLs in YAML parse errors" follows the area: description form and matches the main change. The PR stops YAML parse errors for secret URL fields from quoting the full URL, which the changeset implements in config/common/url.go, with tests in url_test.go and config_test.go.

Full details: Description check

Explanation

The description covers the problem, the fix, the example error change, and the test scope. It fills in the checklist items that apply and gives a release-notes entry. It links related issue #3884 under the issue item, but the template's "Fixes #" line was removed and no new-feature or benchmark items are checked, which is expected for a bugfix. The description uses the repository template's checklist structure, with the template's HTML comment block omitted.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 373edcb and b51ce80.

Files selected for processing: 3

  • config/common/url.go
  • config/common/url_test.go
  • config/config_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

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.

1 participant