Skip to content

findPackageConfigFile crashes when given a missing or deleted Directory #163901

@matanlurey

Description

@matanlurey

I've seen this come up in refactoring tests, but not in real code, and I think it's a bug:

import 'package:file/file.dart';
import 'package:flutter_tools/src/dart/package_map.dart' show findPackageConfigFile;

void example(FileSystem fileSystem) {
  // Pick a clearly non-existent directory.
  final Directory directory = fileSystem.directory('i/do/not/exist');
  print(findPackageConfigFile(directory)); // Expected: null, but throws
}

This is because fileSystem.identicalSync throws if one or more of the paths are missing, and is used and I think this can be fixed by ensuring the path being checked actually exists (if it doesn't, then continue looking).

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.team-toolOwned by Flutter Tool team

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions