(agentcore-gateway) Credentials prefix for Credentials location in GatewayCredentialProvider sets unresonable Default when empty
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
Source: aws/aws-cdk