Skip to content

fix: leave flags nobody set out of the decoded config - #26

Merged
patdowney merged 1 commit into
masterfrom
fix/unset-flags-keep-nil-slices
Nov 14, 2026
Merged

patdowney merged 1 commit into
masterfrom
fix/unset-flags-keep-nil-slices

Conversation

@patdowney

Copy link
Copy Markdown
Contributor

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 as sets [acme self-signed], but only one of acme, self-signed and local is used and events.event-broker.url: is required when event-broker is set.

UnmarshalConfig now 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

  • TestInitConfigLeavesUnsetBlocksNil fails without the fix and passes with it.
  • TestInitConfigKeepsABlockTheConfigSets pins that a block the config sets is kept.
  • make verify passes; connect's cmd config 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

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
@patdowney
patdowney merged commit 13ad921 into master Nov 14, 2026
4 checks passed
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