Skip to content

[PM-33496] Loosen parsing rules by introducing a new Expected value type#127

Merged
Hinton merged 7 commits into
bitwarden:mainfrom
1Password:expected-struct
Apr 24, 2026
Merged

[PM-33496] Loosen parsing rules by introducing a new Expected value type#127
Hinton merged 7 commits into
bitwarden:mainfrom
1Password:expected-struct

Conversation

@rbartlensky

Copy link
Copy Markdown
Contributor

🎟️ Tracking

Solves #122

📔 Objective

Follow-up from our discussion on #126. Let me know what you think!

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

@rbartlensky rbartlensky requested a review from a team as a code owner March 12, 2026 18:45
@bitwarden-bot

Copy link
Copy Markdown

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-33496
Link: https://bitwarden.atlassian.net/browse/PM-33496

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title Loosen parsing rules by introducing a new Expected value type [PM-33496] Loosen parsing rules by introducing a new Expected value type Mar 12, 2026
Comment thread credential-exchange-format/src/editable_field.rs Outdated
@rbartlensky

Copy link
Copy Markdown
Contributor Author

I pushed two more commits which add a bunch of nice utilities to make upgrading to this new version easier. I ran out of time yesterday, so I spent today integrating these new patches into our codebase. Let me know what you think!

@Hinton Hinton self-assigned this Mar 16, 2026

@Hinton Hinton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR makes a lot of sense, I should update our usage and confirm it works well.

Comment thread credential-exchange-format/src/document.rs
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs
@rbartlensky

Copy link
Copy Markdown
Contributor Author

Since this PR went through a few versions, I am going to clean up the history a bit once you're happy with the code.

@Hinton

Hinton commented Mar 31, 2026

Copy link
Copy Markdown
Member

Since this PR went through a few versions, I am going to clean up the history a bit once you're happy with the code.

It will all be squashed in the end so no strict need to do that.

@Hinton

Hinton commented Mar 31, 2026

Copy link
Copy Markdown
Member

I ran out of time reviewing this today. Overall I like the concept but it's a bit verbose and slightly clunky due to handling of valid but wrong field type. I'm experimenting with passing in the editable field type in the UnexpectedField so we avoid duplicating the inner data again. But not quite happy with the result yet.

@Progdrasil Progdrasil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nit, otherwise LGTM

Comment thread credential-exchange-format/src/editable_field.rs Outdated

@Hinton Hinton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the slow review cycle. Overall I quite like this approach, thank you for continuing to iterate on it. I think we're duplicating things and I've suggested some improvements which I think will reduce the duplicated logic. Let me know what you think!

Comment thread credential-exchange-format/src/document.rs
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs Outdated
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs Outdated
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs Outdated
@rbartlensky

Copy link
Copy Markdown
Contributor Author

@Hinton sorry for the long turnaround time -- I think I managed to address most of your comments. I will rebase once you're happy with the current impl

@Hinton Hinton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay.

This looks good, we should rebase it and I think we can merge it. It's somewhat annoying that we have two deserialize one for EditableFieldValue and one for EditableField but there doesn't seem to be any good way of eliminating it.

Comment thread credential-exchange-format/CHANGELOG.md Outdated
Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs Outdated
This helps us with parsing non-compliant CXF (for instance when
someone passes in `string` instead of `concealed-string`) while also
retaining type safety and compliant exports.

@Hinton Hinton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add email and number since those got added to main? Looks good otherwise.

Comment thread credential-exchange-format/src/editable_field.rs
Comment thread credential-exchange-format/src/editable_field.rs Outdated
@rbartlensky

Copy link
Copy Markdown
Contributor Author

@Hinton I think all your comments are now addressed :)

Hinton
Hinton previously approved these changes Apr 23, 2026

@Hinton Hinton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do quick smoke test of this in our implementation tomorrow but should be good to go.

Thanks for working on this!

@rbartlensky

Copy link
Copy Markdown
Contributor Author

I'll do quick smoke test of this in our implementation tomorrow but should be good to go.

Good idea, I'm taking this for a spin as well on our side

Thanks for working on this!

Thanks for bearing with me -- I'm grateful for all the reviews you left on my patches!

@rbartlensky

Copy link
Copy Markdown
Contributor Author

@Hinton I found one thing that made my life a lot easier: a conversion from editable field to string. It looks like it's working as expected on my side :)

@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.61905% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.04%. Comparing base (404693f) to head (48c0cbc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
credential-exchange-format/src/editable_field.rs 55.94% 89 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
- Coverage   66.02%   62.04%   -3.98%     
==========================================
  Files           5        5              
  Lines         518      685     +167     
==========================================
+ Hits          342      425      +83     
- Misses        176      260      +84     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hinton Hinton merged commit 482506e into bitwarden:main Apr 24, 2026
11 of 12 checks passed
@rbartlensky rbartlensky deleted the expected-struct branch April 25, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants