Region from ~/.aws/config includes an inline comment, so every AWS call fails

Open Beginner friendly
#2,939 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
aws, typescript
Domain
cli

Research direction

Start with src/core/region.ts, especially regionFromConfigFile, and compare its handling of shared config values with the @smithy/core/config parseIni behavior described in the issue. Reproduce with a default profile line such as region = us-west-2 # main region and no region environment variables. Done when the CLI resolves us-west-2 and the described AWS command no longer fails.

Written by the indexing model from the issue text.

Description

Description

When no --region, AWS_REGION or AWS_DEFAULT_REGION is set, the CLI reads the region from the
shared config file itself (regionFromConfigFile in src/core/region.ts). It keeps everything
after =, so a comment on the same line becomes part of the region. The AWS SDK's own ini parser
strips such comments, so the same file works with the AWS CLI and SDKs.

Steps to Reproduce
  1. ~/.aws/config:
    [default]
    region = us-west-2 # main region
    
  2. Unset AWS_REGION / AWS_DEFAULT_REGION and run any command, e.g. agentcore harness list --json.
Expected Behavior

The CLI uses us-west-2, as aws configure get region and the SDK do.

Actual Behavior

The region is us-west-2 # main region, and the SDK rejects it:
Region not accepted: region="us-west-2 # main region" is not a valid hostname component.

CLI Version

1.2.0 (current v1.x, a6452a4)

Operating System

Linux

Additional Context

The SDK (@smithy/core/config parseIni) drops #/; comments at line start or after
whitespace. The CLI's parser also matches any key that merely starts with region.

Dominant language
TypeScript
Stars
339
Forks
129
Avg merge
19h 21m
Merged PRs (30d)
125

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/agentcore-cli

All issues in aws/agentcore-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.