Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error with "Instance of '_SimpleUri'" for malformed import. #59606

Open
rakudrama opened this issue Nov 25, 2024 · 2 comments
Open

Strange error with "Instance of '_SimpleUri'" for malformed import. #59606

rakudrama opened this issue Nov 25, 2024 · 2 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE.

Comments

@rakudrama
Copy link
Member

This error message contains Instance of '_SimpleUri'

$ out/ReleaseX64/dart-sdk/bin/dart --packages=/usr/local/google/home/sra/Dart2/sdk/.dart_tool/package_config.json ~/play1/bug1a3v.dart
Error: Invalid package URI 'package:collection':
  Invalid argument (packageUri): Package URIs must start with the package name followed by a '/': Instance of '_SimpleUri'.
../../play1/bug1a3v.dart:1:8: Error: Not found: 'package:collection'
import 'package:collection';
       ^

Source file:

import 'package:collection';
main() {}

If I escape characters in the URI (e.g. replace n with %6E), I can get an error message saying Instance of '_Uri'.

Could Error.toSafeString trust a Uri?
Or perhaps the front-end should format it, since it has the source file string, more like it reports an unparseable URI.

/cc @lrhn @johnniwinther

@rakudrama rakudrama added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Nov 25, 2024
@lrhn
Copy link
Member

lrhn commented Nov 26, 2024

Can't trust just any Uri drive it's a non-final class.
Could perhaps trust _SimpleUri and _Uri.

I don't really want to allow-list a lot of different classes. Maybe we could have a private interface like _SafeToString that implantation classes can implement.
(With some way to avoid that UP(int, String) becomes _SafeToString.)

@johnniwinther johnniwinther added the cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE. label Nov 26, 2024
@johnniwinther
Copy link
Member

cc @jensjoha

copybara-service bot pushed a commit that referenced this issue Nov 27, 2024
Bug: #59606
Change-Id: Id2737637f5074bc7ab4a1647fabe64a95a949218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397760
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Jens Johansen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE.
Projects
None yet
Development

No branches or pull requests

3 participants