chenhg5/cc-connect · error
command is required for type=command
Error message
command is required for type=command
What it means
validateHookConfig requires a Command for hooks whose handler type is "command". A command-type hook executes a shell command when its event fires; without a command there is nothing to run, so the configuration is rejected.
Source
Thrown at core/hooks.go:114
}
return &HookManager{
hooks: valid,
project: project,
shell: shell,
shellFlag: shellFlag,
shellProfile: shellProfile,
client: &http.Client{},
}
}
func validateHookConfig(h HookConfig) error {
if h.Event == "" {
return fmt.Errorf("event is required")
}
switch HookHandlerType(h.Type) {
case HookHandlerCommand:
if h.Command == "" {
return fmt.Errorf("command is required for type=command")
}
case HookHandlerHTTP:
if h.URL == "" {
return fmt.Errorf("url is required for type=http")
}
if !strings.HasPrefix(h.URL, "http://") && !strings.HasPrefix(h.URL, "https://") {
return fmt.Errorf("url must start with http:// or https://")
}
default:
return fmt.Errorf("unknown handler type %q (must be command or http)", h.Type)
}
return nil
}
// Emit dispatches an event to all matching hooks.
func (hm *HookManager) Emit(event HookEvent) {
if hm == nil {
returnView on GitHub (pinned to 4000b2338a)
Solutions
- Add the `command` key with the executable to run for this hook
- Fix the field name spelling (must be `command`, not `cmd`)
- Uncomment or restore the command line that was removed
- Change type to "http" with a url if you intended an HTTP hook instead
Example fix
// before (config.toml) [[hooks]] event = "before_agent" type = "command" // after [[hooks]] event = "before_agent" type = "command" command = "/usr/local/bin/audit-hook.sh"
Defensive patterns
Strategy: validation
Validate before calling
for i, h := range hooks {
if h.Type == "command" && h.Command == "" {
return fmt.Errorf("hooks[%d]: command required for type=command", i)
}
} Try / catch
mgr, err := NewHookManager(hooks)
if err != nil {
slog.Error("invalid hook config", "err", err)
return fmt.Errorf("hook config: %w", err)
} Prevention
- Pair type = "command" with a non-empty command line in the same table
- Don't rename the field to `cmd` — the struct key is `command`
- Lint hook entries in CI before deployment
- When switching a hook from http to command, update its payload fields too
When it happens
Trigger: NewHookManager receives a hook with Type == "command" and an empty Command field — e.g. a [[hooks]] config entry with type = "command" but no command key.
Common situations: Config entry has type = "command" but the command line was omitted or commented out; field misspelled (e.g. `cmd` instead of `command`); converting an http hook to command type without filling in the command.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- event is required
- url is required for type=http
- tmux: 'session' option is required (name of the tmux session
- config: relay.visibility must be "full", "summary", or "none
- config: at least one [[projects]] entry is required
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/6a2f10aa1d8b7601.
Report an issue: GitHub.