Ask questionstasks.DynamoAttributeValue().withB double encoding value?

<!-- description of the bug: -->

I'm passing in a binary value to a step function which ends up getting base64 encoded somewhere along the way and it ends up getting base64 encoded a second time when I'm using withB as below. It's unclear from the current documentation if the string passed to withB should be base64 encoded already but it's type and the example seem to suggest it. If it's supposed to be a string of the raw binary is there a way decode an already base64 encoded string from the TaskInput.

The code I'm using to pass this value in as binary has been used in a couple other places using a couple different languages etc on the receiving end without issue. And no where am I knowingly encoding it a second time within the CDK state machine here.

withB's documentation shows


public withB(value: string): DynamoAttributeValue

value string

Sets an attribute of type Binary.

For example: "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"

Reproduction Steps

<!-- minimal amount of code that causes the bug (if possible) or a reference: -->

    new tasks.DynamoUpdateItem({
        tableName: props.content.tableName,
        partitionKey: {
            name: "ContentID",
            value: new tasks.DynamoAttributeValue().withB(

Error Log

<!-- what is the error message you are seeing? -->


  • CLI Version : 1.36.1 (build 4df7dac)
  • Framework Version: 1.36.1 (build 4df7dac)
  • OS : macOS Catalina 10.15.5 Beta (19F62f)
  • Language : Typescript


<!-- e.g. detailed explanation, stacktraces, related issues, suggestions on how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc -->

This is :bug: Bug Report


Answer questions eikeon

Adding the encoding='binary' positionally toString('binary') in the above workaround results in: AQERFArDrMOOacO0KWJPwpzDk8KEEAfCsFLCnMOQXsO3wp4 vs the expected AQERFArszmn0KWJPnNOEEAewUpzQXvee

closer... another couple characters. Perhaps the wrong flavor of base64 in this work around


Related questions

Issues compiling CDK projects ("TS2300: Duplicate identifier 'IteratorResult'")
cli: cdk deploy issue hot 3
Subnet selection returns more than one per AZ hot 2
cli: synth fails if cdk.out does not exist hot 2
Default policy are getting creating even when Managed policy were created in the Role hot 1
Python dependency libraries are set to latest hot 1
using json instead of a string as context in cdk.json hot 1
Attaching Managed Policy to Role failing hot 1
Access denied when adding an event notification to an existing s3 bucket hot 1
Unable to create CfnSpotFleet using Python hot 1
DBClusterParameterGroup not found: default.aurora5.6 hot 1
aws-ecs: Cannot deploy fargate services with ECR images hot 1
ecs_patterns.ApplicationLoadBalancedFargateService should allow specifying healthCheck path - aws-cdk hot 1
CodeCommitSourceAction tries to add a policy to an imported role hot 1
Using getAtt that returns a list within a string that is joined in the generated template throws an error hot 1
Github User Rank List