Skip to content

Invalid package_config files cause unhandled exceptions and can prevent other packages from being loaded correctly for terminal link provider #5442

@FMorschel

Description

@FMorschel

From dart-lang/sdk#48746:

[H]ere are the analyzer, extension and instrumentation logs:

analyzer.txt
extension.txt(maybe helpful with the error below? Not sure)
InstrumentationLog.txt

From the analyzer log, it seems there was an error.

[16:39:23] [Analyzer] [Info] ==> {"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"file:///D%3A/dev/clones/dart-sdk/sdk/pkg/analysis_server/test/src/services/correction/fix/merge_combinators_test.dart"}},"clientRequestTime":1741808363525}
[16:39:24] [Analyzer] [Info] <== Content-Length: 70464
Content-Type: application/vscode-jsonrpc; charset=utf-8
[16:39:24] [Analyzer] [Info] <== {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"extends_non_class","codeDescription":{"href":"https://dart.dev/diagnostics/extends_non_class"},"message":"Classes can only extend other classes.\nTry specifying a different superclass, or removing the extends clause.","range":{"end":{"character":69,"line":510},"start":{"character":44,"line":510}},"severity":1,"source":"dart"},{"code":"undefined_getter","codeDescription":{"href":"https://dart.dev/diagnostics/undefined_getter"},"message":"The getter 'MERGE_COMBINATORS_HIDE_HIDE' isn't defined for the type 'DartFixKind'.\nTry importing the library that defines 'MERGE_COMBINATORS_HIDE_HIDE', correcting the name to the name of an existing getter, or defining a getter or field named 'MERGE_COMBINATORS_HIDE_HIDE'.","range":{"end":{"character":61,"line":28},"start":{"character":34,"line":28}},"severity":1,"source":"dart"},{"code":"undefined_method","codeDescription":{"href":"https://dart.dev/diagnostics/undefined_method"},"message":"The method 'resolveTestCode' isn't defined for the type 'MergeHideUsingHideTest'.\nTry correcting the name to the name of an existing method, or defining a method named 'resolveTestCode'.","range":{"end":{"character":25,"line":31},"start":{"character":10,"line":31}},"severity":1,"source":"dart"},{"code":"undefined_method","codeDescription":{"href":"https://dart.dev/diagnostics/undefined_method"},"message":"The method 'assertHasFix' isn't defined for the type 'MergeHideUsingHideTest'.\nTry correcting the name to the name of an existing method, or defining a method named 'assertHasFix'.","range":{"end":{"character":22,"line":34},"start":{"character":10,"line":34}},"severity":1,"source":"dart"},{"code":"undefined_method","codeDescription":{"href":"https://dart.dev/diagnostics/undefined_method"},"message":"The method 'createAnalysisOptionsFile' isn't defined for the type 'MergeHideUsingHideTest'.\nTry correcting the name to the name of an existing metho…
[16:39:24] [Analyzer] [Info] <== Content-Length: 214
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"jsonrpc":"2.0","method":"dart/textDocument/publishClosingLabels","params":{"labels":[],"uri":"file:///D:/dev/clones/dart-sdk/sdk/pkg/analysis_server/test/src/services/correction/fix/merge_combinators_test.dart"}}Content-Length: 23909
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"jsonrpc":"2.0","method":"dart/textDocument/publishOutline","params":{"outline":{"children":[{"codeRange":{"end":{"character":1,"line":20},"start":{"character":0,"line":13}},"element":{"kind":"FUNCTION","name":"main","parameters":"()","range":{"end":{"character":9,"line":13},"start":{"character":5,"line":13}},"returnType":"void"},"range":{"end":{"character":1,"line":20},"start":{"character":0,"line":13}}},{"children":[{"codeRange":{"end":{"character":62,"line":25},"start":{"character":2,"line":25}},"element":{"kind":"GETTER","name":"errorCode","range":{"end":{"character":25,"line":25},"start":{"character":16,"line":25}},"returnType":"ErrorCode"},"range":{"end":{"character":62,"line":25},"start":{"character":2,"line":24}}},{"codeRange":{"end":{"character":62,"line":28},"start":{"character":2,"line":28}},"element":{"kind":"GETTER","name":"kind","range":{"end":{"character":18,"line":28},"start":{"character":14,"line":28}},"returnType":"FixKind"},"range":{"end":{"character":62,"line":28},"start":{"character":2,"line":27}}},{"codeRange":{"end":{"character":3,"line":37},"start":{"character":2,"line":30}},"element":{"kind":"METHOD","name":"test_export_hide_hide","parameters":"()","range":{"end":{"character":36,"line":30},"start":{"character":15,"line":30}},"returnType":"Future<void>"},"range":{"end":{"character":3,"line":37},"start":{"character":2,"line":30}}},{"codeRange":{"end":{"character":3,"line":47},"start":{"character":2,"line":39}},"element":{"kind":"METHOD","name":"test_export_hide_hide_lint","parameters":"()","range":{"end":{"character":41,"line":39},"start":{"character":15,"line":39}},"re…
[16:39:27] [General] [Error] Unexpected token '/', "/*error: e"... is not valid JSON
SyntaxError: Unexpected token '/', "/*error: e"... is not valid JSON
    at JSON.parse (<anonymous>)
    at PackageConfigJsonPackageMap.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13921:28)
    at new PackageConfigJsonPackageMap (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13914:14)
    at Function.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13826:24)
    at Function.loadForProject (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13816:20)
    at c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:28591:76
[16:39:27] [General] [Error] Unexpected token '/', "/*error: e"... is not valid JSON
SyntaxError: Unexpected token '/', "/*error: e"... is not valid JSON
    at JSON.parse (<anonymous>)
    at PackageConfigJsonPackageMap.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13921:28)
    at new PackageConfigJsonPackageMap (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13914:14)
    at Function.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13826:24)
    at Function.loadForProject (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13816:20)
    at c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:28591:76
[16:39:27] [General] [Error] Unexpected token '/', "/*error: e"... is not valid JSON
SyntaxError: Unexpected token '/', "/*error: e"... is not valid JSON
    at JSON.parse (<anonymous>)
    at PackageConfigJsonPackageMap.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13921:28)
    at new PackageConfigJsonPackageMap (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13914:14)
    at Function.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13826:24)
    at Function.loadForProject (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13816:20)
    at c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:28591:76
[16:39:27] [General] [Error] Unexpected token '/', "/*error: e"... is not valid JSON
SyntaxError: Unexpected token '/', "/*error: e"... is not valid JSON
    at JSON.parse (<anonymous>)
    at PackageConfigJsonPackageMap.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13921:28)
    at new PackageConfigJsonPackageMap (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13914:14)
    at Function.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13826:24)
    at Function.loadForProject (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13816:20)
    at c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:28591:76
[16:39:27] [General] [Error] Unexpected token '/', "/*error: e"... is not valid JSON
SyntaxError: Unexpected token '/', "/*error: e"... is not valid JSON
    at JSON.parse (<anonymous>)
    at PackageConfigJsonPackageMap.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13921:28)
    at new PackageConfigJsonPackageMap (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13914:14)
    at Function.load (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13826:24)
    at Function.loadForProject (c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:13816:20)
    at c:\Users\felip_0vh5fa6\.vscode\extensions\dart-code.dart-code-3.107.20250311\out\dist\extension.js:28591:76
[16:39:30] [Analyzer] [Info] <== Content-Length: 212
Content-Type: application/vscode-jsonrpc; charset=utf-8
[16:39:30] [Analyzer] [Info] <== {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///D:/dev/clones/dart-sdk/sdk/pkg/analysis_server/test/src/services/correction/fix/merge_combinators_test.dart"}}
[16:39:38] [Analyzer] [Info] <== Content-Length: 93

This is with the Dart SDK project switching from https://github.com/FMorschel/sdk/tree/stale-analysis to 54c8719dfac436f395b4c4078085d5ed8f0dfc51 should do the above.

I'll need to replicate this again if you need more logs, please say so and I'll do it. I'm not sure if this only happened because when swiching I had the merge_combinators_test.dart file opened but from your answer I don't think this is the problem:

@DanTup wrote:

Edit: It's coming from discoverPackageMaps in DartPackageUriLinkProvider.

Although re-reading the error (SyntaxError: Unexpected token '/', "/*error: e"... is not valid JSON) I'm not completely sure if this isn't caused by a corrupt package_config... I could understand an EOF error if the file was partially written, but this seems like there is some invalid JSON in there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions