Repository navigation
fix: leave pointer fields nil unless the config sets them - #27
Merged
Merged
Conversation
v0.12.1 dropped a pointer block whose values were all zero, but viper hands
back a flag's default in the flag's string form, so a block with a duration
("0s") still looked set, and a pointer to a scalar, such as *bool, was
allocated with its zero value. In connect that selected the dynamic
authoriser with no URL and failed every tunnel connection.
UnmarshalConfig now leaves a pointer field nil unless the config file, the
environment or a flag on the command line sets it or something under it,
which viper's IsSet answers without counting flag defaults. A pointer set to
an explicit zero, such as enabled: false, is kept.
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
v0.12.1 (#26) dropped a pointer block whose values were all zero, but viper hands back a flag's default in the flag's string form, so a block containing a duration (
"0s") still looked set, and a pointer to a scalar such as*boolwas allocated with its zero value. In connect this selected the dynamic authoriser with no URL and failed every tunnel connection (unsupported protocol scheme "",/api/accountreturning 500 in the local smoke test).UnmarshalConfignow leaves a pointer field nil unless the config file, the environment or a flag set on the command line gives it, or something under it, a value. This uses viper'sIsSet, which ignores flag defaults. A pointer set to an explicit zero (enabled: false) is kept. The empty-slice handling from #26 is unchanged.Testing
TestInitConfigLeavesUnsetBlocksNilnow includes duration, int and bool fields, and fails on v0.12.1.TestInitConfigDistinguishesAnUnsetPointerFromAnExplicitZerocovers*boolunset versusenabled: false.make verifypasses; connect's tests andtest-scripts/smoke_test_local.shpass against this change.A release (v0.12.2) is needed before connect can adopt cli v0.12.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ