Skip to content

[lint] dart_hooks.yaml example files added in #148 use keys that the hook code never reads (hooks stay disabled) #150

@reidbaker

Description

@reidbaker

Summary

PR #148 committed example dart_hooks.yaml files whose keys don't match the keys the code actually looks for. A user who copies one of these files (or treats it as the reference)
ends up with hooks that silently stay disabled, with no obvious error.

Details

The example files added in #148 use the script filenames as keys:

dart_hooks.yaml, tool/dart_hooks.yaml, tool/dart_hooks/dart_hooks.yaml

agent_dart_format.dart: true
agent_dart_analyze.dart: true

But BaseHook.run() in tool/dart_hooks/lib/src/base_hook.dart gates on each hook's configKey, which is the class name:

  • tool/dart_hooks/lib/src/dart_format_hook.dart → String get configKey => 'DartFormatHook';
  • tool/dart_hooks/lib/src/dart_analyze_hook.dart → String get configKey => 'DartAnalyzeHook';

Since agent_dart_format.dart / agent_dart_analyze.dart are not DartFormatHook / DartAnalyzeHook, yaml.containsKey(configKey) is false and the hook exits via the "key is missing"
branch. The README.md (also updated in #148) documents the correct keys, so the README and the committed example files contradict each other.

Expected

The example dart_hooks.yaml files enable the hooks, matching the README.

Actual

With the committed example files, both hooks are skipped. The log shows:

Hook dart format is disabled (key "DartFormatHook" is missing in configuration).
Hook dart analyze is disabled (key "DartAnalyzeHook" is missing in configuration).

and the hook prints {"decision":"stop"} and exits 0.

Repro

  1. Use any of the dart_hooks.yaml files as committed in Configure format and analyze hooks via YAML #148 (agent_dart_format.dart: true, etc.) at the package root.
  2. Run agent_dart_format/agent_dart_analyze with --log from the .agents directory.
  3. Inspect .agents/dart_format.log / .agents/dart_analyze.log → "disabled (key ... is missing)" instead of "enabled in configuration."

Suggested fix

Update the three committed dart_hooks.yaml files to use the class-name keys that the code reads (and that the README already documents):

DartFormatHook: true
DartAnalyzeHook: true

Optionally, consider also accepting the script-filename keys as aliases, or validating/warning on unrecognized keys so a typo'd/legacy key doesn't silently disable a hook.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions