{"record":{"id":"dd31e242d6a91ebd","repo":"hashicorp/packer","slug":"error-reading-variables-in-s-s","errorCode":null,"errorMessage":"Error reading variables in '%s': %s","messagePattern":"Error reading variables in '(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/flag-kv/flag_json.go","lineNumber":32,"sourceCode":"type FlagJSON map[string]string\n\nfunc (v *FlagJSON) String() string {\n\treturn \"\"\n}\n\nfunc (v *FlagJSON) Set(raw string) error {\n\tf, err := os.Open(raw)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tif *v == nil {\n\t\t*v = make(map[string]string)\n\t}\n\n\tif err := json.NewDecoder(f).Decode(v); err != nil {\n\t\treturn fmt.Errorf(\n\t\t\t\"Error reading variables in '%s': %s\", raw, err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":14,"sourceCodeEnd":38,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/command/flag-kv/flag_json.go#L14-L38","documentation":"CLI error from the -var-file flag handler (FlagJSON.Set): the file was opened successfully but its contents could not be decoded as a JSON object of string variables. The wrapped %s is the encoding/json decode error pinpointing the bad JSON.","triggerScenarios":"Thrown at command/flag-kv/flag_json.go:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the file with a JSON linter and fix syntax errors (trailing commas, missing quotes/braces)","Ensure the top-level value is an object whose values are strings, e.g. {\"image_id\": \"ami-123\"}","Use a .hcl variables file instead if you prefer HCL syntax"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}