Skip to content

fix: prevent panic when home directory cannot be determined#493

Open
pulkit-999 wants to merge 1 commit intodocker:mainfrom
pulkit-999:fix/homedir-panic
Open

fix: prevent panic when home directory cannot be determined#493
pulkit-999 wants to merge 1 commit intodocker:mainfrom
pulkit-999:fix/homedir-panic

Conversation

@pulkit-999
Copy link

Currently, getConfigPath() can return an empty string if the home directory cannot be determined (e.g., in minimal containers or
misconfigured systems). This empty string is then passed to path.Join(), causing a panic: "runtime error: makeslice: len out of range".

This change makes getConfigPath() return an error instead, and adds proper error handling in the caller. The error is wrapped with context to help users understand what went wrong.

@Benehiko
Copy link
Member

If the home directory is misconfigured and the software cannot determine it anyway, why would a panic be the incorrect behavior?

@pulkit-999
Copy link
Author

Missing home directories can happen in minimal containers, CI environments, or misconfigured systems. Expected runtime conditions should return errors, not panic. This provides better user experience.

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.

2 participants