Skip to content

Conversation

@JorTurFer
Copy link
Contributor

@JorTurFer JorTurFer commented Nov 19, 2025

After the PR supporting the RFC7523, there are 2 fields with Secret type inside the Oauth2 struct. This isn't a problem at all, but there are some yaml marshalers in other projects using this pkg (I've discovered this bumping the dep in otel-collector) and they can fail during the marshaling process because one (or more of them) can be empty and it's trying to execute custom marshal logic.

Probably the best option should be handling the case everywhere where custom logic is applied, but it's also true that adding omitempty tag in the source solves it for any usecase.

I've tested this change directly there and it works perfectly

…ng them

Signed-off-by: Jorge Turrado <jorge.turrado@mail.schwarz>
@bwplotka
Copy link
Member

bwplotka commented Nov 20, 2025

Why not set omitempty to all fields?

We got hit by this too in the past when operating things with different versions (operator vs operated thing) using Prometheus config with a new field without omitempty.

@JorTurFer
Copy link
Contributor Author

JorTurFer commented Nov 20, 2025

Why not set omitempty to all fields?

Do you mean here or there? Gotcha, you meant here xD

@bwplotka
Copy link
Member

Everywhere.

At some point I was even adding global options to some YAML projects: goccy/go-yaml#691 ;p

Is there a disadvantage? We never assume something because we don't see the field vs default value (: (we have healthy defaults)

@bwplotka
Copy link
Member

Anyway, let's merge this now .

@bwplotka bwplotka merged commit 04686b2 into prometheus:main Nov 20, 2025
8 checks passed
@JorTurFer
Copy link
Contributor Author

I was updating the branch.. xD Maybe another a follow-up PR or just if someone comes again and cry like me xD

@JorTurFer JorTurFer deleted the fix-omit-empty branch November 20, 2025 08:18
@JorTurFer
Copy link
Contributor Author

Could I ask for a new release? (if it's not planned already). I'll take the new version and update my PRs on otel-collector and prometheus

@bwplotka
Copy link
Member

follow PR is great, sorry for merging too quickly!

@bwplotka
Copy link
Member

Should we add this follow up first, before release?

@JorTurFer
Copy link
Contributor Author

Should we add this follow up first, before release?

Sure! I'm going to prepare it in a couple of minutes and we can ship both together actually

@JorTurFer
Copy link
Contributor Author

well... All the other Secret properties had omitempty set, only the OAuth2 ones didn't have it (sorry because I didn't see 😢 )

Should I add it for string fields too? Maybe it's overkill? If the problem is the parser, probably yes because strict parsing which checks all the fields can fail even for empty strings

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.

2 participants