aws / aws/aws-cdk

(agentcore-gateway) Credentials prefix for Credentials location in GatewayCredentialProvider sets unresonable Default when empty

Open
#37,606 8 comments 0 reactions 0 assignees View on GitHub
aws-cdk-lib bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I need to create CredentialLocation for API Key for GatewayCredentialProvider. I don't need to set credentialsPrefix for my use case, as credentialParameterName is enough. But credentialsPrefix is a required field, so I tried to set the empty string like this:
```
var apiKeyProviderConfigs = List.of(GatewayCredentialProvider
.fromApiKeyIdentityArn(ApiKeyCredentialProviderProps.builder()
.providerArn(apiKeyProviderArn)
.secretArn(apiKeySecretArn)
.credentialLocation(ApiKeyCredentialLocation
.header(ApiKeyAdditionalConfiguration.builder()
.credentialParameterName("x-api-key")
.credentialPrefix("")
.build()))
.build()));
```

It creates Credential Location with the credentialPrefix "Bearer" bei Default, which is what I won't expect when setting an empty value. Of course it doesn't work then. Via the AgentCore Gateway console, setting an empty credentialPrefix works as expected.

The workaround I found, is to set it like this credentialPrefix(" "). Then the value will be trimmed automatically by AgentCore Gateway.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

2.246.0

### Expected Behavior

Setting an empty credentialPrefix sets the empty string as a value.

### Current Behavior

Setting an empty credentialPrefix sets the value to "Bearer"

### Reproduction Steps

Code snippet is given in the description

### Possible Solution

Setting an empty credentialPrefix sets the empty string as a value.

### Additional Information/Context

_No response_

### AWS CDK Library version (aws-cdk-lib)

2.246.0

### AWS CDK CLI version

2.1116.0 (build b7680c1)

### Node.js Version

v22.17.1

### OS

Windows

### Language

Java

### Language Version

25

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start from the GatewayCredentialProvider and ApiKeyAdditionalConfiguration definitions used by the Java reproduction, then trace how an empty credentialPrefix is converted to the default. Add coverage for an explicitly empty prefix and verify that the generated Credential Location preserves the empty string rather than using "Bearer".

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.