fix(firestore): honour Settings.ssl when building the API endpoint - #316
Open
Lyokone wants to merge 1 commit into
Open
fix(firestore): honour Settings.ssl when building the API endpoint#316Lyokone wants to merge 1 commit into
Lyokone wants to merge 1 commit into
Conversation
`Settings.ssl` was a dead field. It was stored, carried through copyWith, and compared in == and hashCode, but nothing ever read it: the endpoint was built with `Uri.https(...)` unconditionally unless FIRESTORE_EMULATOR_HOST was set. A custom `Settings.host` therefore could not be reached over plain HTTP, and `ssl: false` did nothing. The scheme now follows `Settings.ssl` on the non-emulator path. FIRESTORE_EMULATOR_HOST keeps precedence over both `host` and `ssl`, since it is the documented way to point the SDK at an emulator; only the custom-host path changes behaviour. The default stays `ssl: true`, so production callers are unaffected. Note that test/fixtures/helpers.dart already passed `ssl: false` next to a custom host for emulator tests, and worked only because the separate FIRESTORE_EMULATOR_HOST branch happened to hardcode HTTP. Also corrects the `Settings.ssl` doc comment, which described behaviour the field did not have.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Firestore client to respect the ssl setting when constructing the API host URI, allowing connections over plain HTTP when ssl is set to false. It also exposes the firestoreApiHost getter for testing and adds comprehensive unit tests to verify the URI resolution logic under different configurations. There are no review comments, and I have no feedback to provide.
Coverage Report✅ Coverage 75.69% meets 40% threshold Total Coverage: 75.69% Package Breakdown
Minimum threshold: 40% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Settings.sslis a dead field. It is stored, carried throughcopyWith, and compared in==/hashCode— but nothing ever reads it:So a custom
Settings.hostcould not be reached over plain HTTP, andssl: falsesilently did nothing.This is observable today:
test/fixtures/helpers.dartpassesssl: falsenext to a customhostfor emulator tests. It works only becauseFIRESTORE_EMULATOR_HOSTis also set, which takes a separate branch that happens to hardcode HTTP. Remove thessl: falsethere and nothing changes.Fix
The scheme now follows
Settings.sslon the non-emulator path.FIRESTORE_EMULATOR_HOSTkeeps precedence over bothhostandssl, since it is the documented way to point the SDK at an emulator — only the custom-host path changes behaviour. The default remainsssl: true, so production callers are unaffected, and nobody can be depending on the current behaviour because there is no way to observe it._firestoreApiHostis nowfirestoreApiHost(@internal,@visibleForTesting) so the resolution can be asserted directly, matching how other tests in this package reach intosrc/.The
Settings.ssldoc comment described behaviour the field did not have; it is corrected too.Tests
test/firestore_api_host_test.dartcovers five cases: the production default, custom host withssl: true, custom host withssl: false, default host withssl: false, andFIRESTORE_EMULATOR_HOSToverriding both.Each test passes
environmentOverrideso an ambientFIRESTORE_EMULATOR_HOSTcannot leak into the expectations.Verified the tests are not vacuous — with the one-line fix reverted, exactly the two
ssl: falsecases fail and the other three still pass, so they act as regression guards:Full package suite:
+266 -7. The 7 failures are pre-existing onmain— allbundle_test.dart, failing withMetadataServerException: Could not connect to metadata.google.internalbecause they need a project ID from the environment that CI supplies via the emulator. Confirmed identical on a pristine checkout, so there is no regression here.dart analyzeclean,dart formatclean.Note
No CHANGELOG entry:
0.5.3is already released and this repo's release commits collect entries, so I left the next version to the releaser. Happy to add one if you would rather it land with the PR.