Skip to content

fix: name a mistyped --rule or --file instead of "Nothing to fix" - #231

Merged
laaielichter merged 1 commit into
laaielichter:mainfrom
tnalbant:fix/214-name-the-mistake
Nov 17, 2026
Merged

laaielichter merged 1 commit into
laaielichter:mainfrom
tnalbant:fix/214-name-the-mistake

Conversation

@tnalbant

Copy link
Copy Markdown
Contributor

fix --rule, fix --file and migrate --file narrowed what is fixed, and a rule id or a path with a typo matched nothing, so the answer was the same as for a clean project: 0 fixes, Nothing to migrate, exit code 0. In a CI step, or to an agent that reads the output, that says "done, clean".

The four cases this issue lists, on the project from the report:

$ godotwright fix --rule api/infer-varaint
unknown rule "api/infer-varaint"; did you mean api/infer-variant? (fixable rules: ...)   [exit 1]

$ godotwright fix --rule api/unknown-member
api/unknown-member has no mechanical fix (fixable rules: ...)   [exit 1]

$ godotwright fix --file res://mian.gd --write
res://mian.gd does not exist in the project   [exit 1]

$ godotwright migrate --file res://mian.gd
res://mian.gd does not exist in the project   [exit 1]

Nothing is written in any of these cases, also with --write. A correct --rule and --file work as before, and a project with nothing to fix still prints Nothing to fix mechanically. with exit code 0.

Where the check lives. checkRules() and checkFiles() in src/project/options.ts, called at the top of fixProject() (src/fix/fix.ts) and migrateProject() (src/migrate/migrate.ts), so the CLI and the MCP tools godot_fix and godot_migrate fail the same way instead of returning an empty result. The nearest name comes from nearest(), the helper added in #222, so a suggestion matches what the model commands already say; the unknown-rule sentence keeps the unknown rule "x"; did you mean y? shape they use, and the rule without a fix gets its own sentence as the issue asks.

One decision to flag: a rule that exists but has no mechanical fix is exit code 1 too, because the point of the issue is that exit 0 read as "clean". Say if you would rather keep that one at 0.

Tests. test/fix.test.ts covers the typo (nearest rule named, nothing written), the rule without a fix, a name with nothing close, the missing file, the exit codes and the --write case; test/migrate.test.ts the missing --file (and the named file still migrating); test/mcp.test.ts that godot_fix answers with the same two errors. The old fix --file res://missing.gd expectation in test/fix.test.ts asserted Nothing to fix, which is the behaviour this issue changes, so it now asserts the error and exit code 1.

npm run check: typecheck and build clean, 4 tests fail. Three of them fail the same way on a clean worktree of main (9d54706) on this machine: build-api with a path with spaces, and hooks-protect twice. The fourth, test/archetype/check.test.ts, hits vitest's 60 s timeout in the full parallel run and passes alone in 29 s.

CHANGELOG.md is untouched, as the issue asks. The optional --write wording extra in the issue is not in this PR.

…aielichter#214)

`fix --rule` and `--file` (and `migrate --file`) narrowed what is fixed, and
a rule id or path with a typo matched nothing: the answer was the same as for
a clean project, "0 fixes" and exit code 0, which reads as "done, clean" in a
CI step or to an agent.

The check sits in `fixProject` and `migrateProject`, so the CLI and the MCP
tools (`godot_fix`, `godot_migrate`) both get it:

- an unknown rule id is an error that names the nearest rule, from the same
  `nearest()` helper the model commands use: `unknown rule "api/infer-varaint";
  did you mean api/infer-variant? (fixable rules: ...)`, exit code 1;
- a rule that exists but has no mechanical fix says so: `api/unknown-member has
  no mechanical fix (fixable rules: ...)`, exit code 1;
- a `--file` that is not in the project says `res://mian.gd does not exist in
  the project`, exit code 1;
- nothing is written in any of these cases, also with `--write`, and a correct
  rule, file or a project with nothing to fix behaves as before (exit code 0).

Tests cover the typo, the rule without a fix, a name with nothing close, the
missing file for `fix` and `migrate`, the write case, and the two MCP tools.

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @tnalbant, this is exactly what #214 asked for. Putting the check in src/project/options.ts means the CLI and godot_fix/godot_migrate all fail the same way. Exit code 1 for a rule without a mechanical fix is the right call: the whole point is that exit 0 read as "clean".

Verified on 07028c2 (current main is its base): npm run check passes here (typecheck, 2699 tests passed, 1034 skipped without Godot, build). I reran the issue's reproduction against main and this head:

  • fix --rule api/infer-varaint: main says 0 fixes, exit 0. Here it says unknown rule "api/infer-varaint"; did you mean api/infer-variant?, exit 1.
  • fix --rule api/unknown-member: here it says has no mechanical fix, exit 1. fix --rule zzzz gets no suggestion, exit 1.
  • fix --file res://mian.gd --write, fix --file ../outside.gd and migrate --file res://mian.gd: here they say ... does not exist in the project, exit 1, and main.gd is byte-identical afterwards.
  • fix --rule api/infer-variant and fix --file main.gd still propose the fix. A clean project still prints Nothing to fix mechanically. with exit 0.

Mutation check: dropping the checkRules call, or the existence check in checkFiles, makes 4 tests fail in fix/migrate/mcp. CI is 8/8 green. Merging; I will add the CHANGELOG credit.


Generated by Claude Code

@laaielichter
laaielichter merged commit e795ddf into laaielichter:main Nov 17, 2026
8 checks passed
laaielichter added a commit that referenced this pull request Nov 17, 2026
laaielichter added a commit that referenced this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants