{"record":{"id":"ece1f31ff1ec7c29","repo":"chenhg5/cc-connect","slug":"url-is-required-for-type-http","errorCode":null,"errorMessage":"url is required for type=http","messagePattern":"url is required for type=http","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/hooks.go","lineNumber":118,"sourceCode":"\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\n\t}\n\tevent.Project = hm.project\n\tif event.Timestamp.IsZero() {\n\t\tevent.Timestamp = time.Now()","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/hooks.go#L100-L136","documentation":"validateHookConfig requires a URL for hooks whose handler type is \"http\". An HTTP hook POSTs event data to the configured endpoint; an empty URL leaves it with no target, so the configuration is rejected.","triggerScenarios":"NewHookManager receives a hook with Type == \"http\" and an empty URL field — e.g. a [[hooks]] config entry with type = \"http\" but no url key.","commonSituations":"Config entry has type = \"http\" but the url key was omitted; URL accidentally deleted during edits; field misspelled (e.g. `endpoint` instead of `url`).","solutions":["Add the `url` key with the webhook endpoint for this hook","Fix the field name spelling (must be `url`)","Change type to \"command\" with a command if a local handler was intended","Remove the hook entry if it is no longer needed"],"exampleFix":"// before (config.toml)\n[[hooks]]\nevent = \"after_agent\"\ntype = \"http\"\n// after\n[[hooks]]\nevent = \"after_agent\"\ntype = \"http\"\nurl = \"https://example.com/hooks/agent\"","handlingStrategy":"validation","validationCode":"for i, h := range hooks {\n    if h.Type == \"http\" && h.URL == \"\" {\n        return fmt.Errorf(\"hooks[%d]: url required for type=http\", 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":["Always include the `url` key when type = \"http\"","Don't rename the field to `endpoint` — the struct key is `url`","Validate hook config in CI before deployment","Remove obsolete http hooks rather than leaving empty stubs"],"tags":["hooks","validation","config","http"],"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-14T05:17:10.506Z"}