gastownhall/beads · error
ErrVarValidation
ErrVarValidation
Error message
%w: - %s
What it means
ValidateVars() collected one or more per-variable failures from validateVarValue (missing required vars, enum violations, pattern mismatches) and returns them wrapped with the sentinel ErrVarValidation so callers can match with errors.Is. All failures are joined as a bulleted list after a single header line.
Source
Thrown at internal/formula/parser.go:459
// ValidateVars checks that all required variables are provided
// and all values pass their constraints.
func ValidateVars(formula *Formula, values map[string]string) error {
var errs []string
for name, def := range formula.Vars {
val, provided := values[name]
// Check required
if def.Required && !provided {
errs = append(errs, fmt.Sprintf("variable %q is required", name))
continue
}
errs = append(errs, validateVarValue(name, def, val, provided)...)
}
if len(errs) > 0 {
return fmt.Errorf("%w:\n - %s", ErrVarValidation, strings.Join(errs, "\n - "))
}
return nil
}
// ValidateProvidedVars checks enum/pattern/required-empty constraints only
// for variables that are present in values; it does not flag variables that
// are entirely absent. Callers that already surface a more specific
// missing-variable message (e.g. bd mol pour/wisp's hint path) should keep
// using that path for absent vars — this exists so those same callers still
// catch malformed *provided* values, which a presence-only check misses
// (mybd-u2r6).
func ValidateProvidedVars(formula *Formula, values map[string]string) error {
var errs []string
for name, def := range formula.Vars {
val, provided := values[name]
if !provided {View on GitHub (pinned to 71377f2769)
Solutions
- Read each bullet in the error; supply every missing required var and correct enum/pattern violations in the invocation or defaults.
- Match errors.Is(err, ErrVarValidation) in your tooling to print a friendly pre-flight message instead of a stack.
- Update the formula's var defaults or loosen the enum/pattern if the constraint itself is outdated.
Example fix
// before
err := f.ValidateVars(nil) // required vars missing
// after
vars := map[string]string{"env": "prod", "region": "us-east-1"}
if err := f.ValidateVars(vars); err != nil {
if errors.Is(err, ErrVarValidation) { /* show bullets to user */ }
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight check required vars against their definitions before invoking.
for name, def := range f.Vars {
if def.Required {
if _, ok := provided[name]; !ok {
fmt.Printf("missing required var: %s\n", name)
}
}
} Try / catch
if err := f.ValidateVars(provided); err != nil {
if errors.Is(err, ErrVarValidation) {
// print err.Error() verbatim: it already lists each failure as a bullet
}
} Prevention
- Always call ValidateVars before executing a formula; treat ErrVarValidation as user input error, not a bug.
- Keep var defaults in the formula so required vars are rarely absent.
- When changing an enum or pattern, grep callers for the old accepted values.
When it happens
Trigger: Calling ValidateVars (directly or via formula execution paths) when provided var values violate constraints: a required var is absent, a value is not in the var's enum list, or a value does not match the var's pattern regex.
Common situations: CI invoking a formula without all required vars set in the environment or invocation flags; a var default was removed while callers still omit it; an enum value was renamed upstream; a pattern was tightened and previously-valid input now fails.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- no store is open for this workspace
- not found
- no absolute native user directory is available
- ExternalDoltConfig: set either Socket OR (Host, Port), not b
- ExternalDoltConfig: must set Socket or (Host, Port)
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/a6614cbe0c9938d1.
Report an issue: GitHub.