Skip to content

Don't fail with invalid paths in the package map#5910

Merged
DanTup merged 2 commits intomasterfrom
handle-bad-package-map
Feb 18, 2026
Merged

Don't fail with invalid paths in the package map#5910
DanTup merged 2 commits intomasterfrom
handle-bad-package-map

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Feb 17, 2026

If you did pub get on Linux and get that package_config into Windows, this would throw and stop the extension from starting up.

Fixes #5909

If you did `pub get` on Linux and get that package_config into Windows, this would throw and stop the extension from starting up.

Fixes #5909
@DanTup DanTup added this to the v3.130.0 milestone Feb 17, 2026
@DanTup DanTup added is bug fix in flutter Relates to running Flutter apps labels Feb 17, 2026
@DanTup DanTup requested a review from Copilot February 17, 2026 18:10
@DanTup
Copy link
Member Author

DanTup commented Feb 17, 2026

@codex review

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

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 addresses an issue where invalid paths in package_config.json, often due to cross-platform usage, could cause the extension to crash. The fix involves adding error handling to gracefully manage invalid path URIs by catching exceptions and returning undefined instead of throwing. Additionally, a check is added to ensure that the extracted Flutter SDK path actually exists on the filesystem before it's used. The changes are well-tested with new test cases covering various cross-platform path scenarios. My main feedback is to add logging for the caught exceptions to aid in future debugging.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1af040a181

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Prevents the extension from failing to start when a workspace contains a package_config.json generated on a different OS (for example Linux paths opened on Windows), by making package-map URI parsing more resilient and adding coverage for these scenarios.

Changes:

  • Catch invalid file: URI conversions in the package map loader and return undefined instead of throwing.
  • Make extractFlutterSdkPathFromPackagesFile() return undefined when the derived SDK path does not exist.
  • Expand FS/unit tests to cover cross-OS file: URI cases for both flutterRoot and the Flutter package entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/test/dart/utils/fs.test.ts Adds tests for cross-OS file: URIs and updates setup to create a fake Flutter root/bin.
src/shared/utils/fs.ts Ensures extracted Flutter SDK path is only returned if it exists on disk.
src/shared/pub/package_map.ts Wraps URI→path conversion in try/catch to avoid crashes on invalid cross-OS URIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.61%. Comparing base (d3e3938) to head (bbdaafe).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/shared/pub/package_map.ts 54.54% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5910      +/-   ##
==========================================
- Coverage   67.65%   67.61%   -0.04%     
==========================================
  Files         169      169              
  Lines       12976    12979       +3     
  Branches     2564     2566       +2     
==========================================
- Hits         8779     8776       -3     
- Misses       3743     3748       +5     
- Partials      454      455       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DanTup DanTup force-pushed the handle-bad-package-map branch from da7e445 to eaa8a85 Compare February 18, 2026 11:32
@DanTup DanTup force-pushed the handle-bad-package-map branch from eaa8a85 to bbdaafe Compare February 18, 2026 11:42
@DanTup DanTup merged commit b6d043b into master Feb 18, 2026
20 checks passed
@DanTup DanTup deleted the handle-bad-package-map branch February 18, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in flutter Relates to running Flutter apps is bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The server doesn't start if flutter (maybe dart too?) root is an invalid path

2 participants