fix: initialize options.hooks before merging YAML node hooks (#1177)
Some checks are pending
E2E Smoke Tests / e2e-codex (push) Waiting to run
E2E Smoke Tests / e2e-claude (push) Waiting to run
E2E Smoke Tests / e2e-deterministic (push) Waiting to run
E2E Smoke Tests / e2e-mixed (push) Blocked by required conditions
Test Suite / test (ubuntu-latest) (push) Waiting to run
Test Suite / test (windows-latest) (push) Waiting to run
Test Suite / docker-build (push) Waiting to run

When a workflow node defines hooks (PreToolUse/PostToolUse) in YAML but
no hooks exist yet on the options object, applyNodeConfig crashes with
"undefined is not an object" because it tries to assign properties on
the undefined options.hooks.

Initialize options.hooks to {} before the merge loop.

Reproduces with: archon workflow run archon-architect (which uses
per-node hooks extensively).

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alex Siri 2026-04-21 12:52:56 +01:00 committed by GitHub
parent ba4b9b47e6
commit 7ea321419f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -382,6 +382,9 @@ async function applyNodeConfig(
if (Object.keys(builtHooks).length > 0) {
// Merge with existing hooks (PostToolUse capture hook)
const existingHooks = options.hooks as SDKHooksMap | undefined;
if (!options.hooks) {
(options as Record<string, unknown>).hooks = {};
}
for (const [event, matchers] of Object.entries(builtHooks)) {
if (!matchers) continue;
const existing = existingHooks?.[event] as HookCallbackMatcher[] | undefined;