EventBridge putRule/PutRuleCommand: ERROR ValidationException: 1 validation error detected: Value 'aws.partner/sellingpartnerapi.amazon.com/121212121212/amzn1.sp.solution.cb4023df-4e06-4fcf-a8a4-123e3a6544ee' at 'eventBusName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\.\-_A-Za-z0-9]+ #4572
I got the error below when calling either aws-sdks putRule function or @aws-sdk/client-eventBridge's PutRuleCommand instance, in AWS lambda Node20.x runtime environment. Despite adhering to what seems to be the correct format, I received a validation error related to the eventBusName parameter.
Error:
ERROR ValidationException: 1 validation error detected:
Value 'aws.partner/sellingpartnerapi.amazon.com/121212121212/amzn1.sp.solution.cb4023df-4e06-4fcf-a8a4-123e3a6544ee'
at 'eventBusName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\.\-_A-Za-z0-9]+
The error is triggered when using aws-sdkputRule function
Indicating a failure to satisfy the regular expression pattern for the eventBusName parameter.
2024-01-12T19:46:45.918Z cb8e62db-3a75-4ab1-b7e0-b1b75af38105 ERROR ValidationException: 1 validation error detected: Value 'aws.partner/sellingpartnerapi.amazon.com/{aws_account}/amzn1.sp.solution.cb4023df-4e06-4fcf-a8a4-123e3a6544ee' at 'eventBusName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\.\-_A-Za-z0-9]+
at constructor.tTf (/var/task/index.js:704:44721)
at constructor.callListeners (/var/task/index.js:704:88345)
at constructor.emit (/var/task/index.js:704:88052)
at constructor.emitEvent (/var/task/index.js:705:29883)
at constructor.e (/var/task/index.js:705:25430)
at Vxr.runTo (/var/task/index.js:705:1227)
at /var/task/index.js:705:1439
at constructor.<anonymous> (/var/task/index.js:705:25647)
at constructor.<anonymous> (/var/task/index.js:705:29938)
at constructor.callListeners (/var/task/index.js:704:88451)
END RequestId: cb8e62db-3a75-4ab1-b7e0-b1b75af38105
REPORT RequestId: cb8e62db-3a75-4ab1-b7e0-b1b75af38105 Duration: 1231.87 ms Billed Duration: 1232 ms Memory Size: 512 MB Max Memory Used: 504 MB Init Duration: 2986.32 ms
The official AWS documentation for the putRule function
specifies the following pattern for EventBusName parameter
(arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?[/\.\-_A-Za-z0-9]+
However, I believe the correct pattern should be:
(arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?[\/\.\-_A-Za-z0-9]+
But the error I get is different, it mentions that it should satisfy this expression: [\.\-_A-Za-z0-9]+
Both the event bus arn and the event bus name were used and they both result in the same error.
Describe the bug
I got the error below when calling either
aws-sdk
sputRule
function or@aws-sdk/client-eventBridge
'sPutRuleCommand
instance, in AWS lambda Node20.x runtime environment. Despite adhering to what seems to be the correct format, I received a validation error related to theeventBusName
parameter.Error:
Expected Behavior
Creating an Event Rule without any errors as per Amazon Seller Partner API documentation As well as putRule function documentation
Current Behavior
The error is triggered when using
aws-sdk
putRule function Indicating a failure to satisfy the regular expression pattern for theeventBusName
parameter.The official AWS documentation for the putRule function specifies the following pattern for
EventBusName
parameter(arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?[/\.\-_A-Za-z0-9]+
However, I believe the correct pattern should be:
(arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?[\/\.\-_A-Za-z0-9]+
But the error I get is different, it mentions that it should satisfy this expression:
[\.\-_A-Za-z0-9]+
Both the event bus arn and the event bus name were used and they both result in the same error.
Reproduction Steps
Follow the steps in the SP-API documentation to create a destination and an event bus in your AWS. Set up notifications (Amazon EventBridge workflow
Using
aws-sdk
Using
@aws-sdk/client-eventbridge
Possible Solution
I am aware that there has been a similar issue with Serverless, and it has been resolved. You can find more information about the resolution at https://github.com/serverless/serverless/issues/6594.
Additional Information/Context
Note: that I get this error with both
aws-sdk
as well as@aws-sdk/client-eventbridge
SDK version used
"aws-sdk": "2.1534.0" && "@aws-sdk/client-eventbridge": "3.490.0"
Environment details (OS name and version, etc.)
AWS Lambda node 20.x runtime