-
Notifications
You must be signed in to change notification settings - Fork 19
feat: configure insecure DID resolution #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alanshaw
merged 2 commits into
ash/feat/configure-replication-count
from
ash/feat/configure-insecure-rpelication
Apr 15, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long comment here:
There is a Viper registration gap here,
GUPPY_NETWORK_INSECURE_DID_RESOLUTIONsilently won't work, and this is a pattern I think we keep getting wrong across our projects, so I want to flag it here before it lands, not meaning to single out this PR, but it makes a good example of the problem.Adding
InsecureDIDResolutionwith just amapstructuretag registers the field with our struct, but Viper has no idea the key exists until something tells it so. Viper only "knows" a key when one of these has happened:viper.SetDefault("network.insecure_did_resolution", …)viper.BindEnv("network.insecure_did_resolution")viper.BindPFlag("network.insecure_did_resolution", …)viper.AutomaticEnv()is misleading, it does not scan the environment for arbitrary keys. It only consults env vars for keys Viper already knows about (see spf13/viper#761, spf13/viper#584, spf13/viper#1012 for examples). AndUnmarshaldecodes fromAllSettings(), which is built from that same known-keys registry.What this means in practice is that commands like
GUPPY_NETWORK_INSECURE_DID_RESOLUTION=true guppy retrieveare silently ignored. The key isn't registered, so Viper never looks at the env var, andUnmarshalleaves the struct field as its zero value. But, droppinginsecure_did_resolution = trueinto~/.config/guppy/config.tomlworks, because reading the file registers the key as a side effect, which then makes the env var fallback "magically" start working for subsequent runs (until the key is removed from the file again).So the feature appears to work during manual testing with a config file, then breaks the moment someone tries to enable it via an env var in a container/CI environment which, given this is a dev/debug knob that people will reach for from a shell, is where I suspect it'll be used.
More broadly, every
network.*field that has a matching BindPFlag incmd/root.goworks correctly via env vars.network.authorized_retrievalsand nownetwork.insecure_did_resolutiondo not, since they rely on a config file being the source of truth. I suspect we have the same latent bug in other repos where we've leaned on struct tags alone, Piri 100% has this issue in some edge cases.I think the rule we could adopt (and document) is: every Viper-backed config field must be explicitly registered, via one of:
viper.SetDefault(...)at minimum, if it's purely file/env driven, orBindPFlagagainst a cobra flag, preferred for anything user-facing, because it also makes the option discoverable via--help.(I find both options to be tedious, but can't think of a better alternative, some nice-ish work arounds in the viper issues linked to above)
For this specific field I'd lean toward a hidden persistent flag (like we do for
--replicas) bound withBindPFlag, so env var, flag, and config-file paths all go through the same registered key. At the very least, aSetDefault("network.insecure_did_resolution", false)ininitConfigwould make the env-var path work, but we'd still be missing the discoverability that a flag gives us.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am adding
BindPFlagandMarkHiddenforinsecure-did-resolution. Not doing anything withauthorized-retrievalssince it is now legacy and can be removed - at the end of the month there is no network that setting this flag would work with.