Skip to content

Commit

Permalink
There is a missing value in the formatted string for the error, it is
Browse files Browse the repository at this point in the history
passing the interpreter as the string value for the hook name, and is
then printing an empty `%q` for the interpreter value.

There is an addition of the `hookName` passed as a string to the
`logMissingHookInfo` function. This value is passed from the
`runWrappedShellScriptHook` function on [534](https://github.com/buildkite/agent/blob/65ed6aaf3dd3e50f88dee3fbd27714120e558965/internal/job/executor.go#L534).
  • Loading branch information
mcncl committed Aug 26, 2024
1 parent 65ed6aa commit 88bdb20
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 88bdb20

Please sign in to comment.