aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

AbstractProfilesConfigFileScanner does not support comments starting with ";"

Open jaeggir opened this issue 3 years ago • 1 comments

Describe the bug

The config and credential files in ~.awsare according to https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html INI files. Comment lines in INI files do either start with ; or #. AbstractProfilesConfigFileScanner does only treat empty lines or lines starting with # as comment lines: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/internal/AbstractProfilesConfigFileScanner.java#L99

Expected Behavior

Lines starting with ; should also be parsed as comments.

Current Behavior

The parser fails for such files as the line is treated as a key/value pair. See here: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/internal/AbstractProfilesConfigFileScanner.java#L161

Reproduction Steps

  • add "; sample comment" to ~.aws/config
  • use STSAssumeRoleSessionCredentialsProvider to get an AWSCredentialsProvider.

Possible Solution

AbstractProfilesConfigFileScanner.java#L99

 if (line.isEmpty() || line.startsWith("#") || line.startsWith(";")) {

=> I can open a PR if this helps.

Additional Information/Context

No response

AWS Java SDK version used

1.12.195

JDK version used

11.0.12

Operating System and version

OSX 12.3.1

jaeggir avatar Apr 22 '22 12:04 jaeggir

Hi @jaeggir thank you for reaching out, it's a reasonable request.

After a quick test I see Java SDK v2 does consider ; as a comment character. The team is focused in Java SDK v2 feature work, so this probably won't be fixed in v1.

debora-ito avatar Jun 15 '22 22:06 debora-ito