{"record":{"id":"0b17f997da61e7e8","repo":"gastownhall/beads","slug":"invalid-variable-format-s-expected-key-value","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/cook.go","lineNumber":126,"sourceCode":"\tformulaPath string\n}\n\n// parseCookFlags parses and validates cook command flags\nfunc parseCookFlags(cmd *cobra.Command, args []string) (*cookFlags, error) {\n\tdryRun, _ := cmd.Flags().GetBool(\"dry-run\")\n\tpersist, _ := cmd.Flags().GetBool(\"persist\")\n\tforce, _ := cmd.Flags().GetBool(\"force\")\n\tsearchPaths, _ := cmd.Flags().GetStringSlice(\"search-path\")\n\tprefix, _ := cmd.Flags().GetString(\"prefix\")\n\tvarFlags, _ := cmd.Flags().GetStringArray(\"var\")\n\tmode, _ := cmd.Flags().GetString(\"mode\")\n\n\t// Parse variables\n\tinputVars := 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\tinputVars[parts[0]] = parts[1]\n\t}\n\n\t// Validate mode\n\tif mode != \"\" && mode != \"compile\" && mode != \"runtime\" {\n\t\treturn nil, fmt.Errorf(\"invalid mode '%s', must be 'compile' or 'runtime'\", mode)\n\t}\n\n\t// Runtime mode is triggered by: explicit --mode=runtime OR providing --var flags\n\truntimeMode := mode == \"runtime\" || len(inputVars) > 0\n\n\treturn &cookFlags{\n\t\tdryRun:      dryRun,\n\t\tpersist:     persist,\n\t\tforce:       force,\n\t\tsearchPaths: searchPaths,\n\t\tprefix:      prefix,","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/cook.go#L108-L144","documentation":"parseCookFlags in cmd/bd/cook.go parses repeated --var flags for the `bd cook` command. Each value must be of the form key=value; strings.SplitN(v, \"=\", 2) must yield exactly 2 parts. Any --var value without an '=' separator produces this error naming the offending value.","triggerScenarios":"Invoking `bd cook` with a --var flag whose value has no '=', e.g. `--var debug`, `--var =true` is accepted? No — the exact trigger is any v where SplitN(v,\"=\",2) returns one part: `--var debug` (no '='), or an empty value `--var \"\"`.","commonSituations":"Shell variable expansion failing (`--var $KEY` with KEY empty), quoting mistakes that split key=value into two argv entries (`--var key value`), copying docs examples where 'key=value' was meant literally as a template.","solutions":["Write the flag as key=value with a literal equals sign: --var key=value","Quote the whole argument so the shell does not split it: --var \"key=some value\"","Fix empty shell-variable expansions before invoking cook (e.g. ${KEY:?unset})"],"exampleFix":"// before\nbd cook formula --var debug\n// after\nbd cook formula --var debug=true","handlingStrategy":"validation","validationCode":"// validate --var values before invoking bd cook\nfor _, v := range varFlags {\n  if !strings.Contains(v, \"=\") || strings.HasPrefix(v, \"=\") {\n    return fmt.Errorf(\"invalid variable format %q, expected 'key=value'\", v)\n  }\n}","typeGuard":null,"tryCatchPattern":"if err := parseCookFlags(...); err != nil {\n  if strings.Contains(err.Error(), \"invalid variable format\") {\n    // print usage: --var must be key=value\n  }\n  return err\n}","preventionTips":["Always quote --var arguments: --var \"key=value with spaces\"","Guard shell expansions: --var \"key=${KEY:?KEY is unset}\"","Never write --var key value (space instead of =)"],"tags":["cli","argument-parsing","variables","cook"],"backgroundTag":"invalid-flag-format","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}