aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.12k stars 578 forks source link

Profile not found on profile names containing a "+" #5373

Closed tkglaser closed 1 year ago

tkglaser commented 1 year ago

Checkboxes for prior research

Describe the bug

When configuring an AWS profile in ~/.aws/config like this: (although the details of the profile are probably irrelevant)

[profile other+account]
output = json
region = eu-central-1
role_arn = arn:aws:iam::123456789012:role/deployment-role
credential_source = Ec2InstanceMetadata

I get an error saying that the profile cannot be found. I've debugged this and @smithy/shared-ini-file-loader doesn't like AWS CLI profile names which contain a + character. There is a regex called prefixKeyRegex which fails on such names and goes into the wrong code path.

SDK version number

@smithy/shared-ini-file-loader@2.2.1

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.17.1

Reproduction Steps

import { S3 } from "@aws-sdk/client-s3"; import { fromIni } from "@aws-sdk/credential-providers";

const s3 = new S3({ region: "eu-central-1", credentials: fromIni({ profile: "other+account" }), });

async function main() { const result = await s3.listBuckets({}); console.log(result); }

main();

Observed Behavior

node_modules/@aws-sdk/credential-provider-ini/dist-cjs/resolveProfileData.js:30 throw new property_provider_1.CredentialsProviderError(Profile ${profileName} could not be found or parsed in shared credentials file.); ^ CredentialsProviderError: Profile other+account could not be found or parsed in shared credentials file. at resolveProfileData (projects/assume/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/resolveProfileData.js:30:11) at projects/assume/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/fromIni.js:9:56 at async coalesceProvider (projects/assume/node_modules/@smithy/property-provider/dist-cjs/memoize.js:14:24) at async SignatureV4.credentialProvider (projects/assume/node_modules/@smithy/property-provider/dist-cjs/memoize.js:33:24) at async SignatureV4.signRequest (projects/assume/node_modules/@smithy/signature-v4/dist-cjs/SignatureV4.js:106:29) at async projects/assume/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:16:18 at async projects/assume/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46 at async projects/assume/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/region-redirect-endpoint-middleware.js:14:24 at async projects/assume/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/region-redirect-middleware.js:9:20 at async projects/assume/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26 { tryNextLink: true, '$metadata': { attempts: 1, totalRetryDelay: 0 }

Expected Behavior

A listing of buckets

Possible Solution

No response

Additional Information/Context

No response

trivikr commented 1 year ago

The + key is not allowed in profile names, as per SDK Reference

You can use letters, numbers, hyphens ( - ), and underscores ( _ ), but no spaces.

tkglaser commented 1 year ago

Thanks! In that case, my mistake, closing.

trivikr commented 1 year ago

Opening, as this is blocking more customers who're using + in profile name.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.