Skip to content

[gis_web] Make maybeEnum more robust #9093

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

Conversation

kiraDegu
Copy link

@kiraDegu kiraDegu commented Apr 15, 2025

Fixes flutter/flutter#166548

This change improves the robustness of the maybeEnum method in the gis_web plugin. Previously, the method would throw an exception if it encountered an unknown value. Now, it returns null instead, aligning the behavior with the expectations outlined in the issue.

I chose not to add logging for unknown values at this time in order to keep the implementation consistent with the similar method in google_adsense. Additionally, I was unsure what the best logging strategy would be, and I'm not fully convinced that logging unknown enum values is always beneficial, especially given the fluidity of the GIS API.

No repository tests were modified, as the change was minimal and focused. I verified the behavior manually by feeding various inputs to the maybeEnum function and checking that the output matched expectations.

I reviewed the implementation referenced in the issue, but I deliberately avoided using an extension method for consistency with the Flutter repository's style guide.

Let me know if adding logs or converting this into an extension would be preferred, and I’d be happy to revisit.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under1.
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under1.
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under1.
  • All existing and new tests are passing.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Fixes #166548

This change improves the robustness of the `maybeEnum` method in the `gis_web` plugin. Previously, the method would throw an exception if it encountered an unknown value. Now, it returns `null` instead, aligning the behavior with the expectations outlined in the issue.

I chose not to add logging for unknown values at this time in order to keep the implementation consistent with the similar method in `google_adsense`. Additionally, I was unsure what the best logging strategy would be, and I'm not fully convinced that logging unknown enum values is always beneficial, especially given the fluidity of the GIS API.

No repository tests were modified, as the change was minimal and focused. I verified the behavior manually by feeding various inputs to the `maybeEnum` function and checking that the output matched expectations.

I reviewed the implementation referenced in the issue, but I deliberately avoided using an extension method for consistency with the Flutter repository's style guide.

Let me know if adding logs or converting this into an extension would be preferred, and I’d be happy to revisit.
@kiraDegu kiraDegu requested a review from ditman as a code owner April 15, 2025 22:41
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution! I'm marking this as a draft pending the rest of the checklist being completed, as it's not currently ready for review.

No repository tests were modified, as the change was minimal and focused.

Please see the testing policy in the contribution docs. The size of the change is not a consideration in test exemption evaluation.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft April 16, 2025 16:50
@kiraDegu
Copy link
Author

✅ Added unit tests for maybeEnum utility in shared.dart

@ditman
Copy link
Member

ditman commented Apr 22, 2025

Thanks for the fix! I would have landed this, but else beat you to the punch with this fix, here: #8999 (we should have assigned them the underlying issue, sorry!)

@ditman ditman closed this Apr 22, 2025
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.

[gis_web] Make maybeEnum more robust.
3 participants