Skip to content
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

[shared defaults] unable to locate files when environment variables are not set #4444

Closed
grrtrr opened this issue Jun 16, 2022 · 6 comments
Closed
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet.

Comments

@grrtrr
Copy link

grrtrr commented Jun 16, 2022

Describe the bug

The defaults for SharedCredentialsFilename() and SharedConfigFilename() in internal/shareddefaults/shared_config.go rely on UserHomeDir() to return the home directory of the current user:

// internal/shareddefaults/shared_config.go
func UserHomeDir() string {
    if runtime.GOOS == "windows" { // Windows
        return os.Getenv("USERPROFILE")
    }

    // *nix
    return os.Getenv("HOME")
}

When either environment variable is not set, SharedCredentialsFilename() returns ".aws/credentials", and SharedConfigFilename() returns ".aws/config" - relative paths that can not be found.

Expected Behavior

Certain test environments, such as e.g. bazel, clear the HOME environment variable, causing tests that rely on the Golang v1 SDK to fail.

The situation is similar for Windows.

Other AWS SDKs (botocore, AWS C++ SDK >= 1.9) are resilient against changes in the environment, by looking up user information based on the UID of the user, rather than from the environment.

Current Behavior

Clearing $HOME on Linux, or running within bazel test causes the look-up of credential/configuration files ~/.aws/{credentials,config} to fail.

Reproduction Steps

Run code compiled against the Golang v1 SDK by clearing the $HOME variable:

  • unset HOME or
  • env -i ./path/to/golang/executable.

Possible Solution

The standard library in os/user provides user.Current(), which provides the HomeDir field.

Additional Information/Context

Problem is also present in the Golang v2 SDK (same code) -- will create an issue there and refer to here.

SDK version used

v1.44.28

Environment details (Version of Go (go version)? OS name and version, etc.)

Independent of Go version (= all versions).

@grrtrr grrtrr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2022
@RanVaknin RanVaknin self-assigned this Oct 10, 2022
@RanVaknin RanVaknin removed the needs-triage This issue or PR still needs to be triaged. label Oct 18, 2022
@RanVaknin
Copy link
Contributor

pending fix:
#4519

@RanVaknin RanVaknin added the pending-release This issue will be fixed by an approved PR that hasn't been released yet. label Oct 18, 2022
@grrtrr
Copy link
Author

grrtrr commented Oct 19, 2022

pending fix: #4519

Please see comments in PR.

@RanVaknin RanVaknin reopened this Oct 25, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@RanVaknin RanVaknin added the p2 This is a standard priority issue label Mar 29, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@RanVaknin
Copy link
Contributor

https://github.com/aws/aws-sdk-go/pull/4519/files#diff-9f4a894d36a233d5ad83d3a1a3cea61cba356e3a0e77724bae02bc514333217dL35-R40

This line addresses your concern, were you reading the fix out of context?

@grrtrr
Copy link
Author

grrtrr commented Mar 30, 2023

I was referring to this comment, which has since been addressed. Thank you for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet.
Projects
None yet
Development

No branches or pull requests

2 participants