{"record":{"id":"6a2f10aa1d8b7601","repo":"chenhg5/cc-connect","slug":"command-is-required-for-type-command","errorCode":null,"errorMessage":"command is required for type=command","messagePattern":"command is required for type=command","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/hooks.go","lineNumber":114,"sourceCode":"\t}\n\treturn &HookManager{\n\t\thooks:       valid,\n\t\tproject:     project,\n\t\tshell:       shell,\n\t\tshellFlag:   shellFlag,\n\t\tshellProfile: shellProfile,\n\t\tclient:      &http.Client{},\n\t}\n}\n\nfunc validateHookConfig(h HookConfig) error {\n\tif h.Event == \"\" {\n\t\treturn fmt.Errorf(\"event is required\")\n\t}\n\tswitch HookHandlerType(h.Type) {\n\tcase HookHandlerCommand:\n\t\tif h.Command == \"\" {\n\t\t\treturn fmt.Errorf(\"command is required for type=command\")\n\t\t}\n\tcase HookHandlerHTTP:\n\t\tif h.URL == \"\" {\n\t\t\treturn fmt.Errorf(\"url is required for type=http\")\n\t\t}\n\t\tif !strings.HasPrefix(h.URL, \"http://\") && !strings.HasPrefix(h.URL, \"https://\") {\n\t\t\treturn fmt.Errorf(\"url must start with http:// or https://\")\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown handler type %q (must be command or http)\", h.Type)\n\t}\n\treturn nil\n}\n\n// Emit dispatches an event to all matching hooks.\nfunc (hm *HookManager) Emit(event HookEvent) {\n\tif hm == nil {\n\t\treturn","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/hooks.go#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (config.toml)\n[[hooks]]\nevent = \"before_agent\"\ntype = \"command\"\n// after\n[[hooks]]\nevent = \"before_agent\"\ntype = \"command\"\ncommand = \"/usr/local/bin/audit-hook.sh\"","handlingStrategy":"validation","validationCode":"for i, h := range hooks {\n    if h.Type == \"command\" && h.Command == \"\" {\n        return fmt.Errorf(\"hooks[%d]: command required for type=command\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":"mgr, err := NewHookManager(hooks)\nif err != nil {\n    slog.Error(\"invalid hook config\", \"err\", err)\n    return fmt.Errorf(\"hook config: %w\", err)\n}","preventionTips":["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"],"tags":["hooks","validation","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}