{"record":{"id":"9c9c3fa75731afb0","repo":"hashicorp/packer","slug":"the-method-must-be-one-of-v","errorCode":null,"errorMessage":"the `method` must be one of %v","messagePattern":"the `method` must be one of (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/http/data.go","lineNumber":86,"sourceCode":"\n\t// Default to GET if no method is specified\n\tif d.config.Method == \"\" {\n\t\td.config.Method = \"GET\"\n\t}\n\n\t// Check if the input is in the list of allowed methods\n\tvalidMethod := false\n\tallowedMethods := []string{\"HEAD\", \"GET\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\", \"PATCH\"}\n\tfor _, method := range allowedMethods {\n\t\tif method == d.config.Method {\n\t\t\tvalidMethod = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !validMethod {\n\t\terrs = packersdk.MultiErrorAppend(\n\t\t\terrs,\n\t\t\tfmt.Errorf(\"the `method` must be one of %v\", allowedMethods))\n\t}\n\n\tif errs != nil && len(errs.Errors) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}\n\nfunc (d *Datasource) OutputSpec() hcldec.ObjectSpec {\n\treturn (&DatasourceOutput{}).FlatMapstructure().HCL2Spec()\n}\n\n// This is to prevent potential issues w/ binary files\n// and generally unprintable characters\n// See https://github.com/hashicorp/terraform/pull/3858#issuecomment-156856738\nfunc isContentTypeText(contentType string) bool {\n\n\tparsedType, params, err := mime.ParseMediaType(contentType)","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/http/data.go#L68-L104","documentation":"The http datasource only permits a fixed set of HTTP methods (allowedMethods: GET, POST, PUT, DELETE, HEAD, PATCH...). If `method` is set to anything else, Configure rejects the config with the allowed list in the message.","triggerScenarios":"Setting `method = \"get\"` (lowercase, if not accepted), \"OPTIONS\", \"TRACE\", or any misspelled method in the http datasource block.","commonSituations":"Users copy curl-like invocations into Packer config, assume case-insensitivity, or try OPTIONS to probe endpoints.","solutions":["Set `method` to one of the allowed values listed in the error (e.g. GET, POST, PUT, DELETE, HEAD)","Use the exact uppercase spelling from the allowedMethods list","Remove the `method` attribute entirely to default to GET"],"exampleFix":"// before\nmethod = \"get\"\n// after\nmethod = \"GET\"","handlingStrategy":"validation","validationCode":"variable \"http_method\" {\n  type = string\n  validation { condition = contains([\"GET\",\"POST\",\"PUT\",\"DELETE\",\"HEAD\"], var.http_method) error_message = \"unsupported method\" }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use uppercase canonical HTTP method names","Default to omitting `method` (GET) when only reading data","Check the datasource docs for the allowedMethods list"],"tags":["http","datasource","validation","method"],"backgroundTag":"invalid-enum-value","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}