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-14656] Add default value to BaseEnumeratedIntSerializer #4272

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

SaintPatrck
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14656

📔 Objective

Adds a default value to the BaseEnumeratedIntSerializer to handle unknown values during deserialization. This ensures that unknown values will be deserialized to the specified default value instead of throwing an exception.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation 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

Adds a default value to the BaseEnumeratedIntSerializer to handle unknown values during deserialization. This ensures that unknown values will be deserialized to the specified default value instead of throwing an exception.
return values.first { it.serialNameAnnotation?.value == decodedValue }
return values.firstOrNull { it.serialNameAnnotation?.value == decodedValue }
?: default
?: throw IllegalArgumentException("Unknown value $decodedValue")
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@SaintPatrck SaintPatrck enabled auto-merge November 8, 2024 22:01
Copy link
Contributor

github-actions bot commented Nov 8, 2024

Logo
Checkmarx One – Scan Summary & Detailsc61a7898-1426-4c21-9e19-46c69b71b441

No New Or Fixed Issues Found

@SaintPatrck SaintPatrck changed the title Add default value to BaseEnumeratedIntSerializer [PM-14656] Add default value to BaseEnumeratedIntSerializer Nov 8, 2024
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.97%. Comparing base (fe84feb) to head (d2c86a6).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../network/serializer/BaseEnumeratedIntSerializer.kt 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4272   +/-   ##
=======================================
  Coverage   88.97%   88.97%           
=======================================
  Files         445      445           
  Lines       38882    38885    +3     
  Branches     5468     5468           
=======================================
+ Hits        34596    34599    +3     
  Misses       2369     2369           
  Partials     1917     1917           

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

@SaintPatrck SaintPatrck added this pull request to the merge queue Nov 8, 2024
Merged via the queue into main with commit 49642f5 Nov 8, 2024
9 checks passed
@SaintPatrck SaintPatrck deleted the PM-14656/support-unknown-default-enum-values branch November 8, 2024 22:44
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.

2 participants