Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`agentcore dev` container fails with LoginTokenLoadError when using `aws login` credentials

Đang mở Phù hợp với người mới
#2,606 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
80/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
aws, docker, typescript
Lĩnh vực
authentication, cli

Hướng nghiên cứu

Bắt đầu từ ContainerDevRunner.run(), nơi CLI đặt AWS_CONFIG_FILE và AWS_SHARED_CREDENTIALS_FILE trong môi trường được chuyển tiếp vào container. Kiểm tra xem môi trường của container có được xây dựng ở một nơi duy nhất hay không và xem đã có test nào khẳng định các biến được chuyển tiếp đó chưa. Hoàn thành khi container nhận được AWS_LOGIN_CACHE_DIRECTORY trỏ tới /aws-config/login/cache và có một test bao phủ giá trị đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Description

When running a Container-build agent with agentcore dev using aws login credentials (IAM Identity Center login_session), the agent fails with LoginTokenLoadError on every invocation — even immediately after a successful aws login.

The CLI mounts ~/.aws into the container at /aws-config and sets AWS_CONFIG_FILE=/aws-config/config, but does not set AWS_LOGIN_CACHE_DIRECTORY. The botocore login credential provider ignores AWS_CONFIG_FILE and resolves the token cache path independently via ~/.aws/login/cache, which expands to /home/bedrock_agentcore/.aws/login/cache inside the container — a path that does not exist.

Steps to Reproduce
  1. Authenticate with aws login
  2. Run agentcore dev for a Container-build agent
  3. Invoke the agent
Expected Behavior

The agent resolves AWS credentials successfully using the token cached by aws login, matching the behavior seen in CodeZip-build agents.

Actual Behavior

The agent fails immediately with:

botocore.exceptions.LoginTokenLoadError: Error loading login session token:
Unable to load a existing login session for session
arn:aws:iam::<account>:user/<user>.
Please reauthenticate with 'aws login'.

This happens even when the token is freshly issued and not expired.

CLI Version

1.0.0-rc.5

Operating System

macOS

Additional Context

Root cause: In ContainerDevRunner.run(), the CLI sets:

forwardedEnv.AWS_CONFIG_FILE = "/aws-config/config"
forwardedEnv.AWS_SHARED_CREDENTIALS_FILE = "/aws-config/credentials"

But AWS_LOGIN_CACHE_DIRECTORY is not forwarded. Botocore resolves the login token cache in botocore/utils.py::get_login_token_cache_directory():

def get_login_token_cache_directory():
    if 'AWS_LOGIN_CACHE_DIRECTORY' in os.environ:
        return os.path.expanduser(os.environ['AWS_LOGIN_CACHE_DIRECTORY'])
    else:
        return os.path.expanduser(os.path.join('~', '.aws', 'login', 'cache'))

AWS_CONFIG_FILE has no effect on this path. The token cache is present at /aws-config/login/cache inside the container but the provider looks for it at ~/.aws/login/cache (/home/bedrock_agentcore/.aws/login/cache), which doesn't exist.

Fix: Add one line alongside the existing forwarded env vars:

forwardedEnv.AWS_LOGIN_CACHE_DIRECTORY = "/aws-config/login/cache"

Workaround (entrypoint script):

if [ -n "$AWS_CONFIG_FILE" ]; then
    export AWS_LOGIN_CACHE_DIRECTORY="$(dirname "$AWS_CONFIG_FILE")/login/cache"
fi
Ngôn ngữ chính
TypeScript
Star
304
Fork
105
Merge trung bình
16 giờ 14 phút
Pull request đã merge (30 ngày)
186

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws/agentcore-cli

Tất cả issue của aws/agentcore-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.