Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#2,606 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
aws, docker, typescript

Direzione di ricerca

Inizia da ContainerDevRunner.run(), dove la CLI imposta AWS_CONFIG_FILE e AWS_SHARED_CREDENTIALS_FILE nell'ambiente inoltrato al container. Verifica se l'ambiente del container viene costruito in un unico punto e se esiste già un test che controlla quelle variabili inoltrate. È completato quando il container riceve AWS_LOGIN_CACHE_DIRECTORY che punta a /aws-config/login/cache e un test copre quel valore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
304
Fork
105
Merge medio
16h 14m
PR unite (30g)
186

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/agentcore-cli

Tutte le issue di aws/agentcore-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.