{"record":{"id":"9909188f7bdece42","repo":"opentofu/opentofu","slug":"s-s-value-must-not-be-empty-and-only-contain-a","errorCode":null,"errorMessage":"%s \"%s\" value must not be empty and only contain ascii characters","messagePattern":"(.+?) \"(.+?)\" value must not be empty and only contain ascii characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/http/backend.go","lineNumber":142,"sourceCode":"\t\t\t\"headers\": &schema.Schema{\n\t\t\t\tType:     schema.TypeMap,\n\t\t\t\tElem:     &schema.Schema{Type: schema.TypeString},\n\t\t\t\tOptional: true,\n\t\t\t\tValidateFunc: func(cv interface{}, ck string) ([]string, []error) {\n\t\t\t\t\tnameRegex := regexp.MustCompile(\"[^a-zA-Z0-9-_]\")\n\t\t\t\t\tvalueRegex := regexp.MustCompile(\"[^[:ascii:]]\")\n\n\t\t\t\t\theaders := cv.(map[string]interface{})\n\t\t\t\t\terr := make([]error, 0, len(headers))\n\t\t\t\t\tfor name, value := range headers {\n\t\t\t\t\t\tif len(name) == 0 || nameRegex.MatchString(name) {\n\t\t\t\t\t\t\terr = append(err, fmt.Errorf(\n\t\t\t\t\t\t\t\t\"%s \\\"%s\\\" name must not be empty and only contain A-Za-z0-9-_ characters\", ck, name))\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tv := value.(string)\n\t\t\t\t\t\tif len(strings.TrimSpace(v)) == 0 || valueRegex.MatchString(v) {\n\t\t\t\t\t\t\terr = append(err, fmt.Errorf(\n\t\t\t\t\t\t\t\t\"%s \\\"%s\\\" value must not be empty and only contain ascii characters\", ck, name))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, err\n\t\t\t\t},\n\t\t\t\tDescription: \"A map of headers, when set will be included with HTTP requests sent to the HTTP backend\",\n\t\t\t},\n\t\t},\n\t}\n\n\tb := &Backend{Backend: s, encryption: enc}\n\tb.Backend.ConfigureFunc = b.configure\n\treturn b\n}\n\ntype Backend struct {\n\t*schema.Backend\n\tencryption encryption.StateEncryption","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/backend/remote-state/http/backend.go#L124-L160","documentation":"Each value in the http backend 'headers' map must be a non-empty (after strings.TrimSpace) pure-ASCII string; the regex [^[:ascii:]] rejects any character above 0x7F. Validation runs at schema-check time, before any request, because the map is written into outgoing HTTP requests verbatim.","triggerScenarios":"headers = { \"X-Token\" = \"\" }, a value that is only whitespace, or values containing non-ASCII characters such as \"pässwort\", smart quotes, em-dashes, or emoji.","commonSituations":"Copy-pasting tokens from rich-text docs, wikis, or chat clients that silently introduce unicode quotes/dashes; templating secrets where the template renders empty or includes a BOM; i18n characters in default values.","solutions":["Set a non-empty, ASCII-only value for the header named in the error message","Re-type quotes and dashes manually after pasting values from documentation or chat","If a header is optional, remove the entry entirely instead of leaving it empty"],"exampleFix":"# before\nheaders = {\n  \"X-Api-Key\" = \"käy-123\"\n}\n# after\nheaders = {\n  \"X-Api-Key\" = \"kay-123\"\n}","handlingStrategy":"validation","validationCode":"// Validate header values before writing them into the backend config\nfunc validHeaderValues(headers map[string]string) bool {\n    for _, v := range headers {\n        if strings.TrimSpace(v) == \"\" {\n            return false\n        }\n        for _, r := range v {\n            if r > 127 {\n                return false\n            }\n        }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type header values by hand after copying tokens from chat clients or docs","Strip BOMs and newlines when injecting secret values from env files or vaults","Omit optional headers instead of setting them to empty strings"],"tags":["http","backend","headers","validation","ascii"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}