Skip to content

[receiver/prometheus] fix yaml marshaling for prometheus secrets#44602

Merged
codeboten merged 1 commit into
open-telemetry:mainfrom
erikburt:fix/prom-receiver-basic-auth-password-marshaling
Dec 4, 2025
Merged

[receiver/prometheus] fix yaml marshaling for prometheus secrets#44602
codeboten merged 1 commit into
open-telemetry:mainfrom
erikburt:fix/prom-receiver-basic-auth-password-marshaling

Conversation

@erikburt

@erikburt erikburt commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Description

This fixes a bug where the custom marshaler for prometheus/common/config.Secret types was interpreting the value as a yaml document.

Instead of returning the raw bytes, we let the yaml library marshal it as a string, rather than of type Secret.

Link to tracking issue

Fixes #44445

Testing

  • Added a unit test to verify the behaviour.

Documentation

N/A

@erikburt erikburt force-pushed the fix/prom-receiver-basic-auth-password-marshaling branch from b6a0bc1 to 29be32f Compare November 28, 2025 04:28
@erikburt erikburt marked this pull request as ready for review November 28, 2025 04:29
@erikburt erikburt requested review from a team, ArthurSens and dashpole as code owners November 28, 2025 04:29
@github-actions github-actions Bot added the receiver/prometheus Prometheus receiver label Nov 28, 2025

@aknuds1 aknuds1 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.

LGTM, except for my chloggen concern.

Comment thread .chloggen/fix_prom-receiver-basic-auth-password-marshaling.yaml

@aknuds1 aknuds1 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.

LGTM

@erikburt erikburt changed the title [receiver/prometheusreceiver] fix yaml marshaling for prometheus secrets [receiver/prometheus] fix yaml marshaling for prometheus secrets Dec 2, 2025
@ArthurSens ArthurSens added the ready to merge Code review completed; ready to merge by maintainers label Dec 4, 2025
@codeboten codeboten merged commit ccdae64 into open-telemetry:main Dec 4, 2025
210 checks passed
@otelbot

otelbot Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution @erikburt! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

@github-actions github-actions Bot added this to the next release milestone Dec 4, 2025
songy23 pushed a commit that referenced this pull request Dec 10, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Refactor `PromHTTPSDConfig.Unmarshal` and
`PromHTTPClientConfig.Unmarshal` so they call a more specific function
`unmarshalConf`, that knows it won't have to YAML marshal
`commonconfig.Secret` instances. This allows me to remove the custom
YAML marshalling of `commonconfig.Secret`, which is actually buggy as
evidenced by #44602 fixing the same logic in another location. Good
thing it isn't needed :)

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

I'm adding `TestUnmarshalConf`, with a set of sub-tests for relevant
cases. The `targetallocator` coverage improves from 77.7% to 83.6%
versus main.

Additionally, I'm adding
`TestLoadTargetAllocatorConfig/special_characters_in_password`, which
fully verifies that loading a `confmap.Conf` from a YAML file with
special password characters and then unmarshalling into
`targetallocator.Config` works. The old, and non-functioning, code was
supposed to ensure the same.

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Code review completed; ready to merge by maintainers receiver/prometheus Prometheus receiver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prometheus basic auth password starting with YAML directive characters fails

6 participants