Skip to content

fix(web): properly cast Map from JSAny?.dartify() - #18855

Open
kevmoo wants to merge 4 commits into
mainfrom
fix/dartify-map-casts
Open

kevmoo wants to merge 4 commits into
mainfrom
fix/dartify-map-casts

Conversation

@kevmoo

@kevmoo kevmoo commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

On both JS and dart2wasm, JSAny?.dartify() allocates <Object?, Object?>{} for JS objects, so direct as Map<String, T> casts throw TypeError at runtime. This PR fixes and adds browser unit tests for Trace.getAttributes() in firebase_performance_web, RemoteConfig.defaultConfig in firebase_remote_config_web, and User.toJson() in firebase_auth_web.

Verified locally under flutter test --platform=chrome and flutter test --platform=chrome --wasm.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

…erop code

Fixes a runtime TypeError in firebase_performance_web's Trace.getAttributes()
where dartify() on JS objects was incorrectly cast to Map<String, String> instead
of Map<Object?, Object?>.

Also removes unused and broken dartify() casting helpers in firebase_auth_web
and firebase_remote_config_web.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@kevmoo

kevmoo commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request removes the toJson method from the web User class, removes the defaultConfig getter from RemoteConfig, and refactors Trace.getAttributes to handle null or empty attributes more safely, accompanied by new unit tests. Regarding the feedback, using as Map? on the result of dartify() in Trace.getAttributes could still lead to a runtime TypeError if the returned value is not a map; it is recommended to use flow analysis with is Map instead to ensure type safety.

@kevmoo
kevmoo requested review from Lyokone and SelaseKay October 22, 2026 20:05
Comment thread packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart
@kevmoo kevmoo changed the title fix(web): properly cast Map from JSAny?.dartify() and remove dead interop code fix(web): properly cast Map from JSAny?.dartify() Oct 23, 2026
@kevmoo
kevmoo requested a review from SelaseKay October 23, 2026 20:34

This branch has not been deployed

No deployments
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