Skip to content

feat: fail the command on hook errors with AIO_FAIL_ON_HOOK_ERROR - #949

Open
iivvaannxx wants to merge 2 commits into
adobe:masterfrom
iivvaannxx:aio-strict-hooks
Open

iivvaannxx wants to merge 2 commits into
adobe:masterfrom
iivvaannxx:aio-strict-hooks

Conversation

@iivvaannxx

Copy link
Copy Markdown
Contributor

Summary

Adds AIO_FAIL_ON_HOOK_ERROR, off by default. When it is on for a hook, an error from that hook fails the command. Today pre-app-build, post-app-build, pre-app-run and post-app-run only log the error and continue.

runHookOrLog(hookName, ...)
  run hook
  on error
    if AIO_FAIL_ON_HOOK_ERROR is on for hookName
      throw "Hook '<name>' failed: <message>"
    else
      log the error
 build.js, run.js
-  try { await runInProcess(hook, config) } catch (err) { this.log(err) }
+  await runHookOrLog('pre-app-build', hook, config, err => this.log(err))
   reloadEnvOnPreHooks(...)
  • The value takes the list syntax from the base PR, for example pre-app-build,post-app-run. Any other on value means all four hooks.
  • A failing pre-app-build or pre-app-run hook throws before reloadEnvOnPreHooks, so the reload is skipped.
  • The deploy and undeploy hooks already fail the command, and a new deploy test pins that. They are unchanged.

Evidence

  • Before: a failing pre-app-build hook is logged and the build goes on with stale generated files.
    After: with AIO_FAIL_ON_HOOK_ERROR=true the command fails with Hook 'pre-app-build' failed: .... Tests cover a list value that fails only the listed hooks, an all value, off values, and the four call sites. npm test and eslint pass.

Merge Danger

Door: two-way

Blast Radius: hook errors

Behavior is unchanged with the variable off. The helper lives in a new src/lib/hook-runner.js because the command tests automock app-helper. This branch includes the commit from the base PR (list syntax for AIO_RELOAD_ENV_ON_PRE_HOOKS). That commit will drop out of the diff once the base PR merges.

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant