[PM-33358] Loosen parsing strictness for some field types#126
[PM-33358] Loosen parsing strictness for some field types#126rbartlensky wants to merge 3 commits intobitwarden:mainfrom
Conversation
In the wild, I noticed some providers don't respect the spec and send `string` where `concealed-string` is expected, and so on. I think it would be a good idea to accept some of these inconsistencies. While we are less strict about some field types mixing with others, there is still some value in not blindly allowing all field types to mix with each other.
We have a special deserializer for YearMonth, so if the user actually supplies a date we won't be able to parse it properly and the deserialization will fail. However, if the user accidentally used the wrong field type we should allow the date to be reinterpreted.
|
Thank you for your contribution! We've added this to our internal tracking system for review. Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process. |
|
Hey, this is #122. I'm still pondering the optimal solution here, and while casting is one approach which decreases the likelihood of incorrect values it can't handle every scenario. And I think discarding non cast-able values would be unfortunate. Another approach that I think I'm leaning towards is to accept any EditableField and leave it to downstream to handle this would guarantee parsing compatibility but result in more complex implementations and remove type safety on exports for using the most appropriate type. I suspect we could make it more ergonomic by having a |
Somehow I missed this when I checked the issue tracker... sorry about that!
I would hate to lose type-safety on exports as well. The |
|
@rbartlensky I think the pattern should work, not sure if we need the |
Opened #127 instead. The struct is used to ensure it's impossible to create a non-conforming CXF by accident. Closing this one in favor of #127 |
👋 Me again! I have another set of patches that should help with parsing non-conforming CXF.
🎟️ Tracking
📔 Objective
In the wild, I noticed some providers don't respect the spec and
send
stringwhereconcealed-stringis expected, and so on. Ithink it would be a good idea to accept some of these inconsistencies.
My commit messages have a bit more context around the types of issues
I've encountered.
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes