fix: return clear error when --private-key-file path starts with '~'#5859
Open
rafaelperoco wants to merge 1 commit into
Open
fix: return clear error when --private-key-file path starts with '~'#5859rafaelperoco wants to merge 1 commit into
rafaelperoco wants to merge 1 commit into
Conversation
The tilde character is expanded by the shell, not by the Flux CLI, so paths like ~/.ssh/id_ecdsa passed with =value syntax were opened verbatim and failed with a confusing "no such file or directory" error. Detect the leading '~' up front and surface a message pointing users at absolute paths or $HOME instead. Fixes fluxcd#5591. Signed-off-by: Rafael Peroco <rafaelperoco@gmail.com>
0ad391f to
566bbe6
Compare
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
The tilde character is expanded by the shell, not by the Flux CLI, so paths like
~/.ssh/id_ecdsapassed with=valuesyntax (e.g.--private-key-file=~/.ssh/id_ecdsa) were opened verbatim and failed with a confusingno such file or directoryerror.This change detects a leading
~up front inLoadKeyPairFromPathand in thegetAuthOptscode path used bybootstrap git, and returns a clear error pointing users at absolute paths or\$HOMEinstead. Behavior for normal paths is unchanged.Maintainers' position in #5591 was to not auto-expand
~but to surface a better error message, which is what this PR implements.Fixes #5591.
Test plan
ssh key with tilde pathincreate_secret_git_test.goasserting the new errorgo test ./cmd/flux/... ./pkg/manifestgen/sourcesecret/...passesflux create secret git ... --private-key-file=~/.ssh/id_ecdsanow returns the clear message