Skip to content

Conversation

@chwagssd
Copy link
Collaborator

@chwagssd chwagssd commented Dec 29, 2025

  • change #some-key and :some-key to take into account a string that is not allowed to be used in ExpresssionAttributeNames
    • before, this would throw an error during the DB update updateExpression({'some-key': true})
    • even though 'some-key' is valid as an attribute for a db row in dynamodb, just not as an alias
  • updated all of the paths inside of updateExpression() so that consistently makes the key name safe before using it as an alias, not just using it as-is
  • actual key is untouched and still used in the write as the attribute
//before
updateExpression({'some-var': 'some value'});
/* this would actually cause an error when executing the update because of the hyphens in #some-var and :some-var
{
            
            ExpressionAttributeNames: {
              '#some-var': 'some-var'
            },
            ExpressionAttributeValues: {
              ':some-var': 'some value'
            },
            UpdateExpression:
              'SET #some-var = :some-var',
            ReturnValues: 'ALL_NEW',
          }
*/

//after
updateExpression({'some-var': 'some value'});
/*
{
            
            ExpressionAttributeNames: {
              '#some_x2d_var': 'some-var'
            },
            ExpressionAttributeValues: {
              ':some_x2d_var': 'some value'
            },
            UpdateExpression:
              'SET #some_x2d_var = :some_x2d_var',
            ReturnValues: 'ALL_NEW',
          }
*/

Chad Wagner added 2 commits December 24, 2025 17:02
- change `:key` and `:key` to take into account a string that is not allowed to be used in ExpresssionAttributeNames
    - before, this would throw an error during the DB update `updateExpression({'a|b': true})`
    - even though 'a|b' is valid as an attribute for a db row in dynamodb, just not as an alias
- updated all of the paths inside of updateExpression() so that consistently makes the key name safe before using it as an alias, not just using it as-is
- actual key is untouched and still used in the write as the attribute
- instead of using char+ -> _
- use char -> `_x${char.charCodeAt(0).toString(16)}_` (basically char code surrouned by underscores)
@chwagssd chwagssd merged commit a3eade1 into master Dec 30, 2025
3 checks passed
@chwagssd chwagssd deleted the task/key-name-safe-replacement branch December 30, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants