-
Notifications
You must be signed in to change notification settings - Fork 124
File Settings should return error in case the file itself does not exist #437
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,9 @@ func NewFileSettingsSource( | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| func (s *FileSettingsSource) PublicSSHKeyForUsername(string) (string, error) { | ||||||||||||||||||||
| if !s.fs.FileExists(s.settingsFilePath) { | ||||||||||||||||||||
| return "", bosherr.Errorf("File for settings source does not exist: '%s'", s.settingsFilePath) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return "", nil | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
37
to
42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical logic error: must always return an error to enable fallback. The current implementation only returns an error when the settings file is missing (lines 38-40), but returns Per the PR description, the file settings source "does not return an SSH key" regardless of whether its settings file exists. It should always return an error when an SSH key is requested. 🐛 Proposed fix to always return an error func (s *FileSettingsSource) PublicSSHKeyForUsername(string) (string, error) {
- if !s.fs.FileExists(s.settingsFilePath) {
- return "", bosherr.Error("File for settings source does not exist")
- }
- return "", nil
+ return "", bosherr.Error("File settings source does not provide SSH keys")
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valid Point. However I don't know about the history of this and therefore I tried to keep the existing logic in case the file exists There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check multi_settings_source.go for the fallback/iteration logic
cat infrastructure/multi_settings_source.go
echo "---"
# Check git log for PublicSSHKeyForUsername history in file_settings_source.go
git log --oneline -10 -- infrastructure/file_settings_source.go
echo "---"
# Check what interface PublicSSHKeyForUsername belongs to
rg -n "PublicSSHKeyForUsername" --type=go -C3
echo "---"
# Check how PublicSSHKeyForUsername is called in the agent
rg -n "PublicSSHKeyForUsername" --type=go -B5 -A10Length of output: 59807
I also notice that several other sources ( The one remaining edge case worth calling out: if a stemcell config ever places Given that context, the current implementation looks reasonable as a conservative fix. The PR achieves its stated goal. 🧠 Learnings used |
||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.