{"record":{"id":"afdc26fd8059134b","repo":"gastownhall/beads","slug":"invalid-format-s-expected-variable-value-or","errorCode":null,"errorMessage":"invalid format '%s', expected 'variable=value' or 'value=variable'","messagePattern":"invalid format '(.+?)', expected 'variable=value' or 'value=variable'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_distill.go","lineNumber":80,"sourceCode":"func collectSubgraphText(subgraph *MoleculeSubgraph) string {\n\tvar parts []string\n\tfor _, issue := range subgraph.Issues {\n\t\tparts = append(parts, issue.Title)\n\t\tparts = append(parts, issue.Description)\n\t\tparts = append(parts, issue.Design)\n\t\tparts = append(parts, issue.AcceptanceCriteria)\n\t\tparts = append(parts, issue.Notes)\n\t}\n\treturn strings.Join(parts, \" \")\n}\n\n// parseDistillVar parses a --var flag with smart detection of syntax.\n// Accepts both spawn-style (variable=value) and substitution-style (value=variable).\n// Returns (findText, varName, error).\nfunc parseDistillVar(varFlag, searchableText string) (string, string, error) {\n\tparts := strings.SplitN(varFlag, \"=\", 2)\n\tif len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid format '%s', expected 'variable=value' or 'value=variable'\", varFlag)\n\t}\n\n\tleft, right := parts[0], parts[1]\n\tleftFound := strings.Contains(searchableText, left)\n\trightFound := strings.Contains(searchableText, right)\n\n\tswitch {\n\tcase rightFound && !leftFound:\n\t\t// spawn-style: --var branch=feature-auth\n\t\t// left is variable name, right is the value to find\n\t\treturn right, left, nil\n\tcase leftFound && !rightFound:\n\t\t// substitution-style: --var feature-auth=branch\n\t\t// left is value to find, right is variable name\n\t\treturn left, right, nil\n\tcase leftFound && rightFound:\n\t\t// Both found - prefer spawn-style (more natural guess)\n\t\t// Agent likely typed: --var varname=concrete_value","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_distill.go#L62-L98","documentation":"`parseDistillVar` parses `bd mol distill --var` flags, which must contain exactly one `=` with non-empty text on both sides. The flag supports two syntaxes: spawn-style `variable=value` and substitution-style `value=variable`. A flag without `=`, or with an empty side (e.g. `=foo` or `bar=`), is structurally invalid and rejected before any text lookup happens.","triggerScenarios":"Running `bd mol distill --var foo` (no `=`), `--var =foo`, or `--var foo=` from `distillSubgraph` or the proxied-server path. The `strings.SplitN(varFlag, \"=\", 2)` result has length != 2 or an empty part, hitting the `len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\"` branch.","commonSituations":"Quoting mistakes in shell that drop the `=`; forgetting the variable name when only supplying a value; typos like double `==` handled by SplitN into an empty part; copying flags from docs that used placeholder syntax.","solutions":["Use the documented `variable=value` form, e.g. `--var epic_name=auth-refactor`.","Check for shell quoting issues: quote the whole flag (`--var 'name=value'`) if the value contains spaces.","If you intended substitution-style, ensure both sides are non-empty, e.g. `--var 'auth-refactor=epic_name'`."],"exampleFix":"// before\nbd mol distill --epic bd-42 --var epic_name\n// after\nbd mol distill --epic bd-42 --var epic_name=auth-refactor","handlingStrategy":"validation","validationCode":"// shell: validate --var shape before invoking bd\nVAR='epic_name=auth-refactor'\ncase \"$VAR\" in\n  *=*) L=${VAR%%=*}; R=${VAR#*=}\n       [[ -n \"$L\" && -n \"$R\" ]] || { echo \"--var needs non-empty variable and value\"; exit 1; } ;;\n  *)   echo \"--var must be variable=value\"; exit 1 ;;\nesac\nbd mol distill --epic bd-42 --var \"$VAR\"","typeGuard":"func validVarFlag(f string) bool {\n\tp := strings.SplitN(f, \"=\", 2)\n\treturn len(p) == 2 && p[0] != \"\" && p[1] != \"\"\n}","tryCatchPattern":"if err := runDistill(); err != nil && strings.Contains(err.Error(), \"invalid format\") {\n\tfmt.Fprintln(os.Stderr, \"usage: --var variable=value or value=variable\")\n}","preventionTips":["Always quote --var values containing spaces or special characters.","Check for accidental double '==' or missing '=' when composing flags.","Copy the variable=value form from `bd mol distill --help` examples."],"tags":["cli","argument-parsing","flag-format"],"backgroundTag":"invalid-flag-format","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}