{"record":{"id":"f1956c61725eb69f","repo":"gastownhall/beads","slug":"invalid-variable-format-s-expected-key-value-f1956c","errorCode":null,"errorMessage":"invalid variable format '%s', expected 'key=value'","messagePattern":"invalid variable format '(.+?)', expected 'key=value'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/pour.go","lineNumber":81,"sourceCode":"\tattachType string\n}\n\nfunc gatherPourInput(cmd *cobra.Command, args []string) pourInput {\n\tin := pourInput{protoArg: args[0]}\n\tin.dryRun, _ = cmd.Flags().GetBool(\"dry-run\")\n\tin.varFlags, _ = cmd.Flags().GetStringArray(\"var\")\n\tin.assignee, _ = cmd.Flags().GetString(\"assignee\")\n\tin.attachArgs, _ = cmd.Flags().GetStringSlice(\"attach\")\n\tin.attachType, _ = cmd.Flags().GetString(\"attach-type\")\n\treturn in\n}\n\nfunc parseVarFlags(varFlags []string) (map[string]string, error) {\n\tvars := make(map[string]string)\n\tfor _, v := range varFlags {\n\t\tparts := strings.SplitN(v, \"=\", 2)\n\t\tif len(parts) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"invalid variable format '%s', expected 'key=value'\", v)\n\t\t}\n\t\tvars[parts[0]] = parts[1]\n\t}\n\treturn vars, nil\n}\n\nfunc runPour(cmd *cobra.Command, args []string) error {\n\tCheckReadonly(\"pour\")\n\n\tevt := metrics.NewCommandEvent(\"pour\")\n\tdefer func() {\n\t\tif c := metrics.Global(); c != nil {\n\t\t\tc.CloseEventAndAdd(evt)\n\t\t}\n\t}()\n\n\tin := gatherPourInput(cmd, args)\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/pour.go#L63-L99","documentation":"parseVarFlags converts repeated --var flags into a key=value map. Any flag string without an '=' separator cannot be split into key and value, so it throws \"invalid variable format '%s', expected 'key=value'\" naming the offending argument.","triggerScenarios":"Passing a --var argument with no '=' (e.g. --var foo or --var \"foo=\") ... specifically any v where strings.SplitN(v, \"=\", 2) yields fewer than 2 parts — to commands using parseVarFlags: bd pour, wisp create, gatherMolBondInput, or the proxied pour server.","commonSituations":"Users writing `bd pour mol --var count` instead of `--var count=3`; shell quoting stripping the '=' (rare); copy-pasting flag docs where the example value was omitted.","solutions":["Pass variables as key=value: `--var count=3`.","Quote the whole argument if the value contains spaces: `--var \"msg=hello world\"`.","Check each --var flag in the failing command for a missing '='.","Use an empty value explicitly if intended: `--var key=`."],"exampleFix":"// before\nbd pour molecule --var count\n// error: invalid variable format 'count', expected 'key=value'\n// after\nbd pour molecule --var count=3","handlingStrategy":"validation","validationCode":"func validVarFlag(s string) bool {\n    return strings.Contains(s, \"=\") && strings.SplitN(s, \"=\", 2)[0] != \"\"\n}\n// check each --var flag before invoking the command","typeGuard":"func isKeyValue(s string) (key, val string, ok bool) {\n    parts := strings.SplitN(s, \"=\", 2)\n    if len(parts) != 2 || parts[0] == \"\" {\n        return \"\", \"\", false\n    }\n    return parts[0], parts[1], true\n}","tryCatchPattern":"vars, err := parseVarFlags(varFlags)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"invalid variable format\") {\n        return fmt.Errorf(\"usage: --var key=value (got: %s)\", err)\n    }\n    return err\n}","preventionTips":["Always pass variables as key=value","Quote arguments containing spaces or special characters","Validate --var flags in shell wrappers before invoking bd","Use --var key= for intentionally empty values"],"tags":["go","cli","validation","molecule"],"backgroundTag":"invalid-argument-format","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}