Skip to content

fix: leave pointer fields nil unless the config sets them - #27

Merged
patdowney merged 1 commit into
masterfrom
fix/unset-duration-flags
Nov 15, 2026
Merged

patdowney merged 1 commit into
masterfrom
fix/unset-duration-flags

Conversation

@patdowney

Copy link
Copy Markdown
Contributor

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 *bool was allocated with its zero value. In connect this selected the dynamic authoriser with no URL and failed every tunnel connection (unsupported protocol scheme "", /api/account returning 500 in the local smoke test).

UnmarshalConfig now 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's IsSet, which ignores flag defaults. A pointer set to an explicit zero (enabled: false) is kept. The empty-slice handling from #26 is unchanged.

Testing

  • TestInitConfigLeavesUnsetBlocksNil now includes duration, int and bool fields, and fails on v0.12.1.
  • TestInitConfigDistinguishesAnUnsetPointerFromAnExplicitZero covers *bool unset versus enabled: false.
  • make verify passes; connect's tests and test-scripts/smoke_test_local.sh pass 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

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
@patdowney
patdowney merged commit d06ad23 into master Nov 15, 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