arlyon / async-stripe

Async (and blocking!) Rust bindings for the Stripe API
https://payments.rs
Apache License 2.0
453 stars 130 forks source link

Remove prefix validation from ids #530

Closed mzeitlin11 closed 5 months ago

mzeitlin11 commented 5 months ago

Sample implementation for #529. Fixes #529.

arlyon commented 5 months ago

Ideally, we would make this user-configurable. Can the parsing code check some global static that can be set? I am OK with making this opt-in, rather than out. The lack of errors is annoying but, for the core products, we are pretty safe. I would also like to instrument the code with tracing before 1.0 so a trace error on a failed ID would be handy.

EDIT: An example for when this might be useful is if people are using this library to store IDs in their database. Having type level validation is kinda handy. But aside from that TBH I don't really see many benefits so lets rip it out.

mzeitlin11 commented 5 months ago

EDIT: An example for when this might be useful is if people are using this library to store IDs in their database. Having type level validation is kinda handy.

Yeah, that makes sense. We could also add another *Id constructor that explicitly validates the prefix is one of the expected ones if users want to opt-in to that additional safety. I just wanted to avoid the deserialization code relying on ids since it seems like a large compatibility hazard and any id coming from stripe should always be valid.