{"record":{"id":"03411c2092da2f73","repo":"kopia/kopia","slug":"invalid-http-header-q-must-be-key-value","errorCode":null,"errorMessage":"invalid --http-header %q, must be key:value","messagePattern":"invalid --http-header %q, must be key:value","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_notification_configure_webhook.go","lineNumber":40,"sourceCode":"\n\tc.common.setup(svc, cmd)\n\n\tvar httpHeaders []string\n\n\tcmd.Flag(\"endpoint\", \"SMTP server\").StringVar(&c.opt.Endpoint)\n\tcmd.Flag(\"method\", \"HTTP Method\").EnumVar(&c.opt.Method, http.MethodPost, http.MethodPut)\n\tcmd.Flag(\"http-header\", \"HTTP Header (key:value)\").StringsVar(&httpHeaders)\n\tcmd.Flag(\"format\", \"Format of the message\").EnumVar(&c.opt.Format, sender.FormatHTML, sender.FormatPlainText)\n\n\tact := configureNotificationAction(svc, &c.common, webhook.ProviderType, &c.opt, webhook.MergeOptions)\n\n\tcmd.Action(func(ctx *kingpin.ParseContext) error {\n\t\tfor _, h := range httpHeaders {\n\t\t\tconst numParts = 2\n\n\t\t\tparts := strings.SplitN(h, \":\", numParts)\n\t\t\tif len(parts) != numParts {\n\t\t\t\treturn errors.Errorf(\"invalid --http-header %q, must be key:value\", h)\n\t\t\t}\n\t\t}\n\n\t\tc.opt.Headers = strings.Join(httpHeaders, \"\\n\")\n\n\t\treturn act(ctx)\n\t})\n}\n","sourceCodeStart":22,"sourceCodeEnd":49,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_notification_configure_webhook.go#L22-L49","documentation":"Input validation in the webhook notification configure command: each --http-header value must contain exactly one ':' separating key and value, enforced by splitting with strings.SplitN(h, \":\", 2) and requiring 2 parts. Values without a colon are rejected with this errors.Errorf before any profile is touched.","triggerScenarios":"Passing `--http-header` values with no colon at all (e.g. `Authorization` instead of `Authorization: Bearer xyz`); kopia splits on ':' and gets fewer than 2 parts.","commonSituations":"Forgetting the value; passing a header name only; shell quoting mistakes that drop the ':'-containing part.","solutions":["Always provide the header as key:value, e.g. --http-header \"Authorization: Bearer TOKEN\"","Quote the argument in the shell so spaces and colons survive parsing","Note only the FIRST colon separates key from value; colons in the value are fine"],"exampleFix":"// before\n--http-header Authorization\n// after\n--http-header \"Authorization: Bearer eyJ...\"","handlingStrategy":"validation","validationCode":"func validHeader(h string) bool {\n    return strings.Contains(h, \":\") && len(strings.SplitN(h, \":\", 2)) == 2 && strings.SplitN(h, \":\", 2)[0] != \"\"\n}\n// reject invalid headers before invoking kopia\nfor _, h := range headers {\n    if !validHeader(h) { return fmt.Errorf(\"invalid --http-header %q\", h) }\n}","typeGuard":null,"tryCatchPattern":"if err := configureWebhook(ctx); err != nil && strings.Contains(err.Error(), \"invalid --http-header\") {\n    // re-run with corrected key:value arguments\n}","preventionTips":["Always quote header args in the shell","Format as key:value with at least one colon","Add a shell helper that validates header format before invoking kopia"],"tags":["cli","notifications","validation","webhook"],"backgroundTag":"invalid-argument-format","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}