{"record":{"id":"272ea40a30bfc887","repo":"opentofu/opentofu","slug":"no-value-in-arg-s","errorCode":null,"errorMessage":"No '=' value in arg: %s","messagePattern":"No '=' value in arg: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/flags/flag_kv.go","lineNumber":26,"sourceCode":"import (\n\t\"flag\"\n\t\"fmt\"\n\t\"strings\"\n)\n\n// FlagStringKV is a flag.Value implementation for parsing user variables\n// from the command-line in the format of '-var key=value', where value is\n// only ever a primitive.\ntype FlagStringKV map[string]string\n\nfunc (v *FlagStringKV) String() string {\n\treturn \"\"\n}\n\nfunc (v *FlagStringKV) Set(raw string) error {\n\tbefore, after, ok := strings.Cut(raw, \"=\")\n\tif !ok {\n\t\treturn fmt.Errorf(\"No '=' value in arg: %s\", raw)\n\t}\n\n\tif *v == nil {\n\t\t*v = make(map[string]string)\n\t}\n\n\tkey, value := before, after\n\t(*v)[key] = value\n\treturn nil\n}\n\n// FlagStringSlice is a flag.Value implementation which allows collecting\n// multiple instances of a single flag into a slice. This is used for flags\n// such as -target=aws_instance.foo and -var x=y.\ntype FlagStringSlice []string\n\nvar _ flag.Value = (*FlagStringSlice)(nil)\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/command/flags/flag_kv.go#L8-L44","documentation":"FlagStringKV implements Go's flag.Value to parse -var arguments of the form key=value for OpenTofu's CLI. Set splits the raw argument on the first '=' via strings.Cut; when no '=' is present it returns this error verbatim. It is the standard rejection path for a malformed -var flag.","triggerScenarios":"Invoking tofu plan/apply/destroy with '-var key' (no '=' and value), '-var \"key value\"' where the '=' was typo'd to ':' or a space, an empty string argument, or CI scripts that concatenate '-var' with an environment variable that is unset.","commonSituations":"Typos in shell commands, unquoted arguments split by the shell, dynamically built CI/CD variable lists where one value is missing, or copy-pasting -var syntax from docs of tools that use ':' separators.","solutions":["Rewrite the flag as '-var key=value' (equal sign required, e.g. -var environment=prod)","Quote the whole pair if it contains shell metacharacters: -var \"key=value with spaces\"","Move many variables into a .tfvars file and use -var-file=terraform.tfvars instead","If generating args programmatically, validate each contains '=' before passing it to the CLI"],"exampleFix":"# before\ntofu apply -var environment\n\n# after\ntofu apply -var environment=prod","handlingStrategy":"validation","validationCode":"for _, raw := range varArgs {\n    if _, _, ok := strings.Cut(raw, \"=\"); !ok {\n        return fmt.Errorf(\"invalid -var %q: expected key=value form\", raw)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote -var arguments: -var \"key=value with spaces\"","Prefer -var-file for more than two or three variables","In CI, assert each generated var argument contains '=' before invoking tofu","Fail fast in wrapper scripts instead of letting flag parsing reject args late"],"tags":["go","cli","flags","user-input","variables"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}