Skip to content

fix(storage): parse Storage emulator download URLs that use 127.0.0.1 - #18989

Open
SelaseKay wants to merge 2 commits into
mainfrom
fix/storage-emulator-download-url
Open

SelaseKay wants to merge 2 commits into
mainfrom
fix/storage-emulator-download-url

Conversation

@SelaseKay

@SelaseKay SelaseKay commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

FirebaseStorage.refFromURL rejected a Storage emulator download URL when the host was 127.0.0.1. The emulator listens on that address, and getDownloadURL from a client connected to it returns http://127.0.0.1:9199/v0/b/<bucket>/o/<object>?alt=media&token=.... The parser only treated localhost and 10.0.2.2 as emulator hosts, so this URL was parsed as a Cloud Storage URL, did not match, and the call threw.

partsFromHttpUrl now treats any http or https URL whose path is /v<version>/b/<bucket>/o/<object> as a Firebase Storage download URL, on whatever host and port it uses. Cloud Storage URLs on storage.googleapis.com and storage.cloud.google.com that do not use that path are unchanged.

Fixes #18988

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • 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.

Test plan

  • flutter test test/utils_test.dart test/firebase_storage_test.dart in packages/firebase_storage/firebase_storage passes, including 127.0.0.1, https, a LAN address, and [::1].
  • CI storage unit tests and the storage end-to-end suite pass accepts a Storage emulator download URL from 127.0.0.1.

The existing emulator cases use localhost, which the parser already allows. These tests use the host the Storage emulator listens on.

@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 adds integration and unit tests to verify that Firebase Storage correctly parses and accepts emulator download URLs using the 127.0.0.1 IP address. Specifically, it introduces a new integration test in instance_e2e.dart and a corresponding unit test in utils_test.dart, while also refactoring an existing localhost parsing test. I have no feedback to provide as there are no review comments and the changes are well-implemented.

The emulator puts 127.0.0.1 or a LAN address in getDownloadURL. Match the download path instead of allowing only localhost and 10.0.2.2.
@SelaseKay
SelaseKay marked this pull request as ready for review November 19, 2026 15:17

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.

[firebase_storage]: refFromURL fails when using firebase emulator

2 participants