Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-14646: Fix JSON decoding errors #1122

Merged
merged 4 commits into from
Nov 11, 2024

Conversation

matt-livefront
Copy link
Collaborator

@matt-livefront matt-livefront commented Nov 8, 2024

🎟️ Tracking

PM-14646 - Fix JSON decoding errors for invalid CipherRepromptType, SecureNoteType, decimal policy timeout minutes
PM-13105 - [iOS] Users getting "An Error has occurred" and can't access their vaults

📔 Objective

This fixes the following JSON decoding errors:

Invalid CipherRepromptType:

Cannot initialize CipherRepromptType from invalid Int value 65

Invalid SecureNoteType:

Cannot initialize SecureNoteType from invalid Int value 2

Unexpected decimal when decoding a vault timeout policy minutes property:

( "CodingKeys(stringValue: \"policies\", intValue: nil)", "_JSONKey(stringValue: \"Index 7\", intValue: 7)", "CodingKeys(stringValue: \"data\", intValue: nil)", "_JSONKey(stringValue: \"minutes\", intValue: nil)" )
Unable to decode AnyCodable value.

Fixes:

  • For the two enum errors, I added a @DefaultValue property wrapper that will use a default value if the item is unable to be decoded, either because it's missing or invalid. Both of these enums have reasonable default values that we could use in the case of an invalid value.
  • For the policy enum, I added support for AnyCodable to decode Double values. This is then used to convert the value to an Int if that's what we're expecting when we attempt to use the value.

⏰ 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

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release/2024.11-rc1@e6cf148). Learn more about missing BASE report.

Additional details and impacted files
@@                  Coverage Diff                   @@
##             release/2024.11-rc1    #1122   +/-   ##
======================================================
  Coverage                       ?   89.43%           
======================================================
  Files                          ?      682           
  Lines                          ?    43109           
  Branches                       ?        0           
======================================================
  Hits                           ?    38556           
  Misses                         ?     4553           
  Partials                       ?        0           

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

Copy link
Contributor

github-actions bot commented Nov 8, 2024

Logo
Checkmarx One – Scan Summary & Details395e047f-8f2f-49e4-bca8-71888a934fdc

No New Or Fixed Issues Found

Copy link
Contributor

@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

👍🏻 I like it! Makes us more robust.

My only thought is if there might be other places we want to make something be @DefaultValue, though I can't name any offhand. Worst case is we apply it as we find it, I suppose.

@matt-livefront
Copy link
Collaborator Author

My only thought is if there might be other places we want to make something be @DefaultValue, though I can't name any offhand. Worst case is we apply it as we find it, I suppose.

I had that thought too, but I didn't want to introduce too many changes here. I can take another pass through separately and see if there's other places we could apply this (enums are the most susceptible to failures around this).

@matt-livefront matt-livefront merged commit 2a07971 into release/2024.11-rc1 Nov 11, 2024
8 checks passed
@matt-livefront matt-livefront deleted the matt/PM-14646-decoding-errors branch November 11, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants