Page MenuHomePhabricator

[identity] Fix log_out_user DDB expression error
ClosedPublic

Authored by bartek on Dec 21 2023, 2:56 AM.
Tags
None
Referenced Files
F3398740: D10423.diff
Mon, Dec 2, 12:18 AM
Unknown Object (File)
Mon, Nov 18, 5:46 AM
Unknown Object (File)
Thu, Nov 7, 12:52 AM
Unknown Object (File)
Oct 18 2024, 5:37 AM
Unknown Object (File)
Oct 18 2024, 5:37 AM
Unknown Object (File)
Oct 18 2024, 5:37 AM
Unknown Object (File)
Oct 18 2024, 5:37 AM
Unknown Object (File)
Oct 16 2024, 7:04 AM
Subscribers

Details

Summary

Noticed that log_out_user fails when deleting device from legacy DDB table. At least on Localstack.
The error thrown from update_item() call is as following:

ServiceError(ServiceError { source: UpdateItemError { kind: Unhandled(Unhandled { source: Error { code: Some("ValidationException"), message: Some("Invalid UpdateExpression: Internal server error"), ...)
`

Reading AWS docs, I noticed they either hardcode map keys or use expressio attribute names for map keys, not values. This solved the issue.
docs, example SO answer

Test Plan

Error log diappears in D10422 Commtest CI job after I rebased on this diff.
That diff is the first one that uses log_out_user function.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Dec 21 2023, 3:17 AM
bartek added inline comments.
services/identity/src/database.rs
700–705

We use expression_attribute_names for device ID key here and it works

This snippet is a bit unreadable, below is simplified version

let update_expression =
     format!("SET {}.#deviceID = :v", USERS_TABLE_DEVICES_ATTRIBUTE);
   let expression_attribute_names =
     HashMap::from([("#deviceID".to_string(), device_id.clone())]);
   let expression_attribute_values =
     HashMap::from([(":v".to_string(), AttributeValue::M(device_info))]);
This revision is now accepted and ready to land.Dec 21 2023, 5:56 AM