{"record":{"id":"16c940e373ab6c14","repo":"kopia/kopia","slug":"invalid-format-16c940","errorCode":null,"errorMessage":"invalid format","messagePattern":"invalid format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"notification/sender/webhook/webhook_sender_options.go","lineNumber":27,"sourceCode":"\t\"github.com/kopia/kopia/notification/sender\"\n)\n\n// Options defines Webhook sender options.\ntype Options struct {\n\tEndpoint string `json:\"endpoint\"`\n\tMethod   string `json:\"method\"`\n\tFormat   string `json:\"format\"`\n\tHeaders  string `json:\"headers\"` // newline-separated list of headers (key: value)\n}\n\n// ApplyDefaultsAndValidate applies default values and validates the configuration.\nfunc (o *Options) ApplyDefaultsAndValidate(_ context.Context) error {\n\tif o.Method == \"\" {\n\t\to.Method = \"POST\"\n\t}\n\n\tif err := sender.ValidateMessageFormatAndSetDefault(&o.Format, sender.FormatPlainText); err != nil {\n\t\treturn errors.Wrap(err, \"invalid format\")\n\t}\n\n\tu, err := url.ParseRequestURI(o.Endpoint)\n\tif err != nil {\n\t\treturn errors.Errorf(\"invalid endpoint\")\n\t}\n\n\tif u.Scheme != \"http\" && u.Scheme != \"https\" {\n\t\treturn errors.Errorf(\"invalid endpoint scheme, must be http:// or https://\")\n\t}\n\n\tif o.Format == \"\" {\n\t\to.Format = sender.FormatPlainText\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/notification/sender/webhook/webhook_sender_options.go#L9-L45","documentation":"Thrown by webhook Options.ApplyDefaultsAndValidate when sender.ValidateMessageFormatAndSetDefault rejects the configured message format. The format must be one of the sender package's supported values; anything else is rejected.","triggerScenarios":"Creating or updating webhook notification config with `format` set to an unsupported string (e.g. \"xml\", \"rich-text\", case variants like \"HTML\").","commonSituations":"Typo or wrong assumption about supported formats in the notification profile config; copying config from another tool with different format names.","solutions":["Omit the `format` field to get the default (text/plain).","Set `format` to a supported value such as \"text/plain\" (see sender.FormatPlainText and siblings).","Check sender.ValidateMessageFormatAndSetDefault for the exact list of accepted formats.","Fix the casing—format values are compared exactly."],"exampleFix":"// before\n{\"format\": \"xml\"}\n// after\n{\"format\": \"text/plain\"}","handlingStrategy":"validation","validationCode":"switch opts.Format {\ncase \"\", sender.FormatPlainText /* plus other supported formats */ :\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported format %q\", opts.Format)\n}","typeGuard":null,"tryCatchPattern":"if err := opts.ApplyDefaultsAndValidate(ctx); err != nil {\n    if strings.Contains(err.Error(), \"invalid format\") {\n        return fmt.Errorf(\"use a supported format, e.g. %q\", sender.FormatPlainText)\n    }\n    return err\n}","preventionTips":["Omit the `format` field to accept the default.","Copy format values only from the sender package constants, not from memory.","Reject unknown format strings in config CI checks."],"tags":["config","validation","webhook","notifications"],"backgroundTag":"invalid-enum-value","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"}