Page MenuHomePhabricator

[services] Helper function to parse userID from AttributeValue
ClosedPublic

Authored by varun on Jul 27 2022, 1:36 PM.
Tags
None
Referenced Files
F3390947: D4656.id15069.diff
Sat, Nov 30, 1:40 AM
Unknown Object (File)
Tue, Nov 26, 8:37 PM
Unknown Object (File)
Fri, Nov 8, 10:56 AM
Unknown Object (File)
Oct 27 2024, 6:16 PM
Unknown Object (File)
Oct 5 2024, 12:10 AM
Unknown Object (File)
Oct 5 2024, 12:10 AM
Unknown Object (File)
Oct 5 2024, 12:10 AM
Unknown Object (File)
Oct 5 2024, 12:08 AM

Details

Summary

Returns the userID String if present, otherwise returns the appropriate error

Depends on D4648

Test Plan

Tested in subsequent diff that uses helper

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Jul 27 2022, 1:49 PM
tomek added inline comments.
services/identity/src/database.rs
403–419 ↗(On Diff #15025)

The code isn't specific to user_id: this name is used only as a name in match statement. Maybe we can make this method more generic by changing its name to e.g. parse_attribute_value? We can also consider making this an implementation of Into<String> (not sure if this is possible, as we're converting Option<AttributeValue>).

One issue is error handling. For more generic name, we could introduce a new parameter with keyName. For Into I don't see how we could have this handling... maybe Into<Result<String, DBItemError>>?

Overall, my point is that this code would be repeated a lot of times if we want to have similar functions for other AttributeValues. It would be great if we could avoid this.

This revision is now accepted and ready to land.Jul 28 2022, 1:53 AM
services/identity/src/database.rs
403–419 ↗(On Diff #15025)

I'll make this more general before landing

services/identity/src/database.rs
403–419 ↗(On Diff #15025)

It looks like this diff was landed without this improvement @varun

services/identity/src/database.rs
403–419 ↗(On Diff #15025)

Ah, sorry, it is updated, but not fully. We still use user_id name which is now incorrect.

services/identity/src/database.rs
403–419 ↗(On Diff #15025)

ah, oops, will fix now