-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The Trap: The API has a subtle "footgun" regarding .value vs .toString()/parse().
id.valuereturns the raw Base32 string (e.g.,AD836J3H9NPT2).id.toString()returns the full string with checksum (e.g.,task_list/AD836J3H9NPT2T).ResourceId.parse()strictly requires the checksum.- The Workflow Failure: Developers naturally want to use the "clean" ID in URLs (e.g.,
/lists/{id}). If they useid.valuefor this, and then try to reconstruct the ID later (e.g.,ResourceId.parse('task_list/$idFromUrl')), it fails with "Checksum mismatch" because the checksum char is missing. This is exactly what broke our app.
Initial Suggestions:
- Add
id.uid(orid.code): A property that returns the value + checksum (e.g.,AD836J3H9NPT2T). This is the "safe" string to use in URLs or DB keys if you aren't storing the prefix. - Rename
.valueto.rawValue: To make it explicit that it's incomplete/unsafe for parsing. - Enhance
parse(): Maybe allowparse()to accept a valid raw value if a flag is set (e.g., strict: false), calculating the checksum itself? (Though this weakens the "typo-proof" feature). - Documentation: Explicitly warn that id.value strips the checksum and cannot be fed back into parse() even with the prefix.
- The package is solid (the checksum saved us from a mismatch!), but this specific interaction flow is counter-intuitive.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels