Repository navigation
fix: leave flags nobody set out of the decoded config - #26
Merged
Merged
Conversation
Viper answers for every bound flag, so since flags were bound under their config keys a slice flag nobody set decoded as an empty slice, and a pointer block was allocated. Neither equals its zero value, so a check for whether a block is set, such as dioad/net's tls.ServerConfig.Check, saw every block as set and rejected configs that did not mention it. UnmarshalConfig now decodes an empty slice as nil and leaves out a pointer block whose values are all zero. A config that sets a block to nothing but zero values reads as not setting it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ
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.
Summary
Since flags are bound under their config keys (v0.12.0), viper answers for every bound flag, set or not. A slice flag nobody set therefore decoded as an empty slice, and an unset pointer block was allocated. Neither equals its zero value, so a check for whether a block is set (for example dioad/net's
tls.ServerConfig.Check) saw every block as set. In connect this rejected valid configs at startup with findings such assets [acme self-signed], but only one of acme, self-signed and local is usedandevents.event-broker.url: is required when event-broker is set.UnmarshalConfignow decodes an empty slice as nil and leaves out a pointer block whose values are all zero.Behaviour change
A config that sets a pointer block to nothing but zero values reads as not setting it.
Testing
TestInitConfigLeavesUnsetBlocksNilfails without the fix and passes with it.TestInitConfigKeepsABlockTheConfigSetspins that a block the config sets is kept.make verifypasses; connect'scmdconfig tests pass against this change.A v0.12.1 release is needed before connect can adopt cli v0.12.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ