(bedrockagentcore): ApiKeyCredentialLocation.header cannot omit the credential prefix

Open Beginner friendly
#39,693 1 comment 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
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start at ApiKeyCredentialLocation.header() and the GatewayCredentialProvider.fromApiKeyIdentityArn() usage shown in the reproduction. Check the generated CloudFormation template for an empty credentialPrefix; the issue says the property should be omitted so a custom header can send a bare token. Confirm the resulting template no longer includes CredentialPrefix.

Written by the indexing model from the issue text.

Description

needs-triage
Describe the bug

ApiKeyCredentialLocation.header() cannot send an API key without a prefix. An omitted credentialPrefix falls back to 'Bearer ', and '' is rendered as-is, which CloudFormation rejects (CredentialPrefix has minLength: 1).

Regression Issue
  • Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version

No response

Expected Behavior

A way to send a bare token in a custom header (for example PRIVATE-TOKEN: <token>), with CredentialPrefix omitted from the template.

Current Behavior

Either a Bearer prefix is always sent, or the deployment fails on the empty string.

Reproduction Steps
agentcore.GatewayCredentialProvider.fromApiKeyIdentityArn({
  providerArn,
  secretArn,
  credentialLocation: agentcore.ApiKeyCredentialLocation.header({
    credentialParameterName: 'PRIVATE-TOKEN',
    credentialPrefix: '',
  }),
});
Possible Solution

Treat '' as "no prefix" and omit the property. Workaround today: addPropertyDeletionOverride on the target.

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.276.0

AWS CDK CLI version

n/a

Node.js Version

24

OS

n/a

Language

TypeScript

Language Version

No response

Other information

No response

Dominant language
TypeScript
Stars
13k
Forks
4.7k
Avg merge
4d 3h
Merged PRs (30d)
98

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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/aws-cdk

All issues in aws/aws-cdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.