Skip to content

fix(claude): stop writing hook events Claude Code's schema rejects - #15558

Closed
yzxcj797 wants to merge 3 commits into
stablyai:mainfrom
yzxcj797:fix/claude-hook-event-schema-15548
Closed

yzxcj797 wants to merge 3 commits into
stablyai:mainfrom
yzxcj797:fix/claude-hook-event-schema-15548

Conversation

@yzxcj797

Copy link
Copy Markdown
Contributor

Fixes #15548.

What changed

Claude Code validates hooks event names against its settings schema and skips the entire settings.json when it meets an unknown key. Four events Orca injects are OpenClaude-only (StopFailure, PostToolUseFailure, TeammateIdle, PermissionRequest), so installing the Claude hooks silenced every user setting in ~/.claude/settings.json — env, statusLine, enabledPlugins, everything — with the Settings Error banner shown in the issue.

  • CLAUDE_EVENTS remains the master list — OpenClaude emits those events (the comments document why each exists) and keeps receiving all of them in .openclaude/settings.json.
  • getEventsForSettings() filters the list to the schema-valid subset (SessionStart, UserPromptSubmit, Stop, SubagentStart, SubagentStop, PreToolUse, PostToolUse) for the .claude variant.
  • applyManagedHooks() additionally sweeps managed entries under the rejected keys, so a config written by an older Orca heals on the next install: keys holding only managed entries disappear, user-authored entries in those keys survive. Without this, existing installs would stay broken until the user edited the file by hand (the workaround the issue describes).
  • getStatus() and installRemote() use the same per-variant list, so remote .claude installs stop writing the rejected keys too and status no longer reports partial for events Claude never accepts.

Nothing functional is lost for Claude Code: it never emitted those four events, so the hooks could not fire there — they only poisoned the file.

Verification

  • vitest run src/main/claude/hook-service.test.ts — 19/19, including two new cases: the heal sweep (pre-Claude Code hooks: StopFailure is not a valid hook event — causes entire settings.json to be skipped #15548 config with managed StopFailure/TeammateIdle entries + a user entry under PermissionRequest → keys dropped/kept correctly, env untouched) and the remote install asserting the four rejected keys are absent.
  • OpenClaude tests unchanged and passing (still installs the full set, incl. StopFailure).
  • remote-hook-service-installers 24/24 — Grok/Kimi keep their own event lists, untouched.
  • pnpm run typecheck:node clean.
  • Pre-existing local failures on managed-hook-stdin-lifecycle + devin hook-service reproduce on an unmodified tree (Windows-local, unrelated).

Claude Code validates hooks event names against its settings schema and
skips the ENTIRE settings.json when it meets an unknown key, so the
OpenClaude-only events Orca injected (StopFailure, PostToolUseFailure,
TeammateIdle, PermissionRequest) silenced every user setting in
~/.claude/settings.json — env, statusLine, enabledPlugins (stablyai#15548).

CLAUDE_EVENTS stays the master list (OpenClaude emits those events and
still gets all of them), but the Claude variant now filters to the
schema-valid subset via getEventsForSettings(), and applyManagedHooks()
sweeps managed entries under the rejected keys so a config written by an
older Orca heals on the next install — user entries in those keys
survive, the key only disappears when nothing is left. getStatus() and
installRemote() follow the same per-variant list.
@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86d094c9-e95b-4872-b593-0d9114be326d

📥 Commits

Reviewing files that changed from the base of the PR and between ff81f5a and ed0bead.

📒 Files selected for processing (2)
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-settings.ts
💤 Files with no reviewable changes (1)
  • src/main/claude/hook-settings.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Claude hook handling now derives supported events from configured settings. Claude excludes OpenClaude-only events, while OpenClaude retains all events. Local and remote installation pass settings to applyManagedHooks. Unsupported event keys are removed during cleanup, including user-authored and non-array entries. Tests cover local, Windows, remote, and cleanup behavior.

Merge Risk: 🟡 Moderate · up to ed0be

The change stops Orca from adding unsupported Claude hook events and removes managed entries, but user-authored entries under those unsupported keys can still cause Claude Code to reject the entire settings file and disable unrelated settings. Merge readiness is moderate until those remaining invalid keys are handled or explicitly accepted by the owner.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: preventing Claude Code from receiving unsupported hook events.
Description check ✅ Passed The description explains the problem, implementation, linked issue, and verification steps with sufficient detail for review.
Linked Issues check ✅ Passed The changes satisfy issue #15548 by filtering unsupported events, preserving valid settings, and cleaning invalid entries during installation.
Out of Scope Changes check ✅ Passed The changes are limited to Claude hook filtering, cleanup, status detection, remote installation, and related tests.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bef7f6fe-1883-4d96-b874-efc12c2a64a5

📥 Commits

Reviewing files that changed from the base of the PR and between d541982 and f2228c2.

📒 Files selected for processing (3)
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-service.ts
  • src/main/claude/hook-settings.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/main/claude/hook-settings.ts Resolved
Review follow-up: keeping a user-authored entry under an unsupported
event key left the key in place, and Claude Code rejects the whole
settings.json over the unknown key regardless of who wrote the entry —
the user's env/statusLine stayed dead exactly as before the heal. In a
schema-validating Claude Code an entry under such a key can never fire
anyway, so removing the key loses nothing there; OpenClaude lists no
unsupported keys, so user config in .openclaude is untouched.
@yzxcj797

Copy link
Copy Markdown
Contributor Author

Good catch — addressed in ff81f5a. The sweep now deletes a rejected key unconditionally: Claude Code skips the whole settings.json over the unknown key no matter who authored the entry, so the user's env/statusLine stayed just as dead with the key kept, and in a schema-validating Claude Code an entry under such a key can never fire anyway (nothing functional is lost). OpenClaude lists no unsupported keys, so user config under .openclaude is untouched. Test updated to require PermissionRequest (user entry included) to be removed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d5d2112e-a19a-443e-a41a-4bd87e19d49a

📥 Commits

Reviewing files that changed from the base of the PR and between f2228c2 and ff81f5a.

📒 Files selected for processing (2)
  • src/main/claude/hook-service.test.ts
  • src/main/claude/hook-settings.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/main/claude/hook-settings.ts Resolved
Review follow-up: the Array.isArray guard skipped non-array values under
a rejected key, and Claude Code rejects the whole settings.json over the
unknown key no matter what its value looks like — a string or object
under TeammateIdle poisoned the file exactly like a managed list did.
The key is now deleted unconditionally; regression case added.
@yzxcj797
yzxcj797 force-pushed the fix/claude-hook-event-schema-15548 branch from 7bd17fb to ed0bead Compare August 20, 2026 06:50
@yzxcj797

Copy link
Copy Markdown
Contributor Author

Valid — the Array.isArray guard left a non-array value under a rejected key in place, and Claude Code rejects the file over the key regardless of its value shape. Deleted unconditionally in ed0bead, with a non-array PostToolUseFailure regression case in the heal test. 19/19 + typecheck clean.

@nwparker

Copy link
Copy Markdown
Contributor

Thank you @yzxcj797 for this PR and for digging into the settings schema rejection. The same fix landed in #23614, which writes only the hook events and statusLine the installed Claude accepts, so I am closing this as superseded. Much appreciated.

@nwparker nwparker closed this Oct 24, 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.

Claude Code hooks: StopFailure is not a valid hook event — causes entire settings.json to be skipped

2 participants