Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when hook cannot be run due to missing interpreter #2948

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/job/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func logOpenedHookInfo(l shell.Logger, debug bool, hookName, path string) {
}
}

func logMissingHookInfo(l shell.Logger, wrapperPath string) {
func logMissingHookInfo(l shell.Logger, hookName, wrapperPath string) {
// It's unlikely, but possible, that the script wrapper was spontaneously
// deleted or corrupted (it's usually in /tmp, which is fair game).
// A common setup error is to try to run a Bash hook in a container or other
Expand All @@ -445,7 +445,7 @@ func logMissingHookInfo(l shell.Logger, wrapperPath string) {
if err != nil {
// It's reasonable to assume the script wrapper was spontaneously
// deleted, or had something equally horrible happen to it.
l.Errorf("The %s hook failed to run - perhaps the wrapper script %q was spontaneously deleted", wrapperPath)
l.Errorf("The %s hook failed to run - perhaps the wrapper script %q was spontaneously deleted", hookName, wrapperPath)
return
}
interpreter := strings.TrimPrefix(shebang, "#!")
Expand All @@ -458,7 +458,7 @@ func logMissingHookInfo(l shell.Logger, wrapperPath string) {
// than ENOENT.
return
}
l.Errorf("The %s hook failed to run - perhaps the script interpreter %q is missing", interpreter)
l.Errorf("The %s hook failed to run - perhaps the script interpreter %q is missing", hookName, interpreter)
}

func (e *Executor) runWrappedShellScriptHook(ctx context.Context, hookName string, hookCfg HookConfig) error {
Expand Down Expand Up @@ -531,7 +531,7 @@ func (e *Executor) runWrappedShellScriptHook(ctx context.Context, hookName strin
// program we tried to exec, even if the missing file/directory was
// actually the interpreter specified on the shebang line.
// Try to figure out which part is missing from the wrapper.
logMissingHookInfo(e.shell.Logger, script.Path())
logMissingHookInfo(e.shell.Logger, hookName, script.Path())
}

return err
Expand Down