claude-code - 💡(How to fix) Fix [BUG] /doctor schema validator rejects exec-form (args[]) hooks added in 2.1.139

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

/doctor reports the following error for any hook entry that uses the exec-form args: string[] field (introduced in v2.1.139) without also setting a legacy command string:

Code Example

Settings (<path>/settings.json › hooks.PreToolUse.0.hooks.0.command):
  Expected string, but received undefined

---

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          { "type": "command", "args": ["echo", "hi"], "timeout": 1000 }
        ]
      }
    ]
  }
}

---

{
  "attachment": {
    "type": "hook_success",
    "hookName": "PreToolUse:Bash",
    "hookEvent": "PreToolUse",
    "exitCode": 0,
    "durationMs": 12
  },
  "version": "2.1.139"
}
RAW_BUFFERClick to expand / collapse

What happens

/doctor reports the following error for any hook entry that uses the exec-form args: string[] field (introduced in v2.1.139) without also setting a legacy command string:

Settings (<path>/settings.json › hooks.PreToolUse.0.hooks.0.command):
  Expected string, but received undefined

The validator still requires command as a string even when args is present. The runtime correctly accepts and executes the exec form, so /doctor's schema check has fallen out of sync with the runtime and the v2.1.139 changelog entry.

Expected behavior

/doctor should accept a {type: "command", args: [...]} hook entry as valid — either by treating command as optional when args is present, or by validating args as an alternative.

Minimal repro

~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          { "type": "command", "args": ["echo", "hi"], "timeout": 1000 }
        ]
      }
    ]
  }
}

Run /doctor — get command: Expected string, but received undefined.

Evidence the runtime accepts this form

From a live session transcript (~/.claude/projects/<flat>/<session>.jsonl):

{
  "attachment": {
    "type": "hook_success",
    "hookName": "PreToolUse:Bash",
    "hookEvent": "PreToolUse",
    "exitCode": 0,
    "durationMs": 12
  },
  "version": "2.1.139"
}

The hook fires, exits 0, and returns the expected JSON — matching the v2.1.139 changelog: "Added hook args: string[] field (exec form) that spawns the command directly without a shell, so path placeholders never need quoting."

Related

  • #58119 — docs gap for the same args field. Distinct from this report (that one is purely about the hooks reference page).

Environment

  • Claude Code 2.1.139
  • Linux x86_64

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

/doctor should accept a {type: "command", args: [...]} hook entry as valid — either by treating command as optional when args is present, or by validating args as an alternative.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] /doctor schema validator rejects exec-form (args[]) hooks added in 2.1.139