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

Improve diagnostic reporting on invalid analysis options #56943

Open
MohammadNezarAldalati opened this issue Oct 23, 2024 · 7 comments
Open

Improve diagnostic reporting on invalid analysis options #56943

MohammadNezarAldalati opened this issue Oct 23, 2024 · 7 comments
Labels
analyzer-analysis-options analyzer-ux analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@MohammadNezarAldalati
Copy link

MohammadNezarAldalati commented Oct 23, 2024

  • I created a new flutter project, then I run dart analyze and got this error:
Internal error: Failed to handle request: analysis.setAnalysisRoots
Null check operator used on a null value
#0      _LintConfig._parseYaml.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:analyzer/src/lint/config.dart:161:48)
#1      CastMap.forEach.<anonymous closure> (dart:_internal/cast.dart:286:8)
#2      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#3      CastMap.forEach (dart:_internal/cast.dart:285:13)
#4      MapView.forEach (dart:collection/maps.dart:347:10)
#5      _LintConfig._parseYaml.<anonymous closure>.<anonymous closure> (package:analyzer/src/lint/config.dart:155:54)
#6      CastMap.forEach.<anonymous closure> (dart:_internal/cast.dart:286:8)
#7      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#8      CastMap.forEach (dart:_internal/cast.dart:285:13)
#9      MapView.forEach (dart:collection/maps.dart:347:10)
#10     _LintConfig._parseYaml.<anonymous closure> (package:analyzer/src/lint/config.dart:144:46)
#11     _HashMap.forEach (dart:collection-patch/collection_patch.dart:153:15)
#12     MapView.forEach (dart:collection/maps.dart:347:10)
#13     _LintConfig._parseYaml (package:analyzer/src/lint/config.dart:117:16)
#14     new LintConfig.parseMap (package:analyzer/src/lint/config.dart:38:62)
#15     parseConfig (package:analyzer/src/lint/config.dart:15:25)
#16     AnalysisOptionsImplExtensions.applyOptions (package:analyzer/src/analysis_options/apply_options.dart:229:18)
#17     ContextBuilderImpl._createOptionsMap (package:analyzer/src/dart/analysis/context_builder.dart:210:15)
#18     ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:135:15)
#19     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:108:36)
#20     ContextManagerImpl._createAnalysisContexts.performContextRebuildGuarded.performContextRebuild (package:analysis_server/src/context_manager.dart:549:40)
<asynchronous suspension>
#21     ContextManagerImpl._createAnalysisContexts.performContextRebuildGuarded (package:analysis_server/src/context_manager.dart:694:11)
<asynchronous suspension>
#22     _CancellingTaskQueue.queue.<anonymous closure> (package:analysis_server/src/context_manager.dart:978:15)
<asynchronous suspension>
#23     ContextManagerImpl.setRoots (package:analysis_server/src/context_manager.dart:364:5)
<asynchronous suspension>
#24     LegacyAnalysisServer.setAnalysisRoots (package:analysis_server/src/legacy_analysis_server.dart:793:9)
<asynchronous suspension>
#25     AnalysisSetAnalysisRootsHandler.handle (package:analysis_server/src/handler/legacy/analysis_set_analysis_roots.dart:46:7)
<asynchronous suspension>
#26     LegacyAnalysisServer.handleRequest.<anonymous closure>.<anonymous closure> (package:analysis_server/src/legacy_analysis_server.dart:577:11)
<asynchronous suspension>
#27     OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14)
<asynchronous suspension>
#28     LegacyAnalysisServer.handleRequest.<anonymous closure> (package:analysis_server/src/legacy_analysis_server.dart:558:7)
<asynchronous suspension>


null
[RequestError code: SERVER_ERROR, message: Null check operator used on a null value]

General info

  • Dart 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "macos_arm64"
  • on macos / Version 14.6.1 (Build 23G93)
  • locale is en-OM

Project info

  • sdk constraint: '^3.5.3'
  • dependencies: cupertino_icons, flutter, flutter_riverpod, riverpod
  • dev_dependencies: custom_lint, flutter_lints, flutter_test, riverpod_lint
@dart-github-bot
Copy link
Collaborator

Summary: The user is experiencing an error when running dart analyze in a new Flutter project. The error message indicates a null check operator used on a null value, likely stemming from an issue with parsing the lint configuration file.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Oct 23, 2024
@MohammadNezarAldalati
Copy link
Author

  • it seems an error in my analysis_options.yaml file.

@mraleph
Copy link
Member

mraleph commented Oct 23, 2024

This still should not just crash but should report a readable error.

@mraleph mraleph reopened this Oct 23, 2024
@mraleph
Copy link
Member

mraleph commented Oct 23, 2024

cc @pq

@keertip keertip added analyzer-crash-report Issues which have been reported due to an analysis server crash P2 A bug or feature request we're likely to work on labels Oct 23, 2024
@pq
Copy link
Member

pq commented Oct 23, 2024

The unsafe null check was fixed by @DanTup in bbe6f23. We do have some analysis options validation so in common cases errors will be reported.

@MohammadNezarAldalati if you can reproduce the file in a state that crashes for you I can look and see if we're reporting anything on it today.

Thanks!

@pq pq added the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Oct 23, 2024
@MohammadNezarAldalati
Copy link
Author

MohammadNezarAldalati commented Oct 23, 2024

@pq
I just wrote a none valid yaml by mistake in analysis_options.yaml and that what cause the error when run dart analyze:

linter:
  rules:
    analyzer:
      plugins:
        - custom_lint

and then I notice it and fix it:

linter:
  rules:

analyzer:
  plugins:
    - custom_lint

@a-siva a-siva removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Oct 23, 2024
@pq
Copy link
Member

pq commented Oct 23, 2024

Great. Thanks!

@pq pq changed the title running dart analyze not working Improve diagnostic reporting on invalid analysis options Oct 23, 2024
@pq pq added analyzer-warning Issues with the analyzer's Warning codes analyzer-ux analyzer-analysis-options P3 A lower priority bug or feature request and removed needs-info We need additional information from the issue author (auto-closed after 14 days if no response) analyzer-crash-report Issues which have been reported due to an analysis server crash P2 A bug or feature request we're likely to work on labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-analysis-options analyzer-ux analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants