gastownhall/beads · error
invalid mol_type: %s
Error message
invalid mol_type: %s
What it means
Thrown when the value supplied to `mol_type = <value>` is not a valid MolType after lowercasing (i.e. MolType.IsValid() returns false). Indicates a typo or an unsupported molecule-type literal.
Source
Thrown at internal/query/evaluator.go:493
switch field {
case "pinned":
filter.Pinned = &boolVal
case "ephemeral":
filter.Ephemeral = &boolVal
case "template":
filter.IsTemplate = &boolVal
}
return nil
}
func (e *Evaluator) applyMolTypeFilter(comp *ComparisonNode, filter *types.IssueFilter) error {
if comp.Op != OpEquals {
return fmt.Errorf("mol_type only supports = operator")
}
mt := types.MolType(strings.ToLower(comp.Value))
if !mt.IsValid() {
return fmt.Errorf("invalid mol_type: %s", comp.Value)
}
filter.MolType = &mt
return nil
}
// applyMetadataFilter handles metadata.<key>=<value> queries (GH#1406).
func (e *Evaluator) applyMetadataFilter(comp *ComparisonNode, filter *types.IssueFilter) error {
if comp.Op != OpEquals {
return fmt.Errorf("metadata fields only support = operator")
}
key := strings.TrimPrefix(comp.Field, "metadata.")
if err := storage.ValidateMetadataKey(key); err != nil {
return err
}
if filter.MetadataFields == nil {
filter.MetadataFields = make(map[string]string)
}
filter.MetadataFields[key] = comp.ValueView on GitHub (pinned to 71377f2769)
Solutions
- Correct the value to a valid MolType literal (case-insensitive; it is lowercased before validation).
- List valid molecule types from the types package / docs (types.MolType values where IsValid() is true).
- Validate user-supplied type values before interpolating them into queries.
Example fix
// before bd list 'mol_type = moleculee' // after bd list 'mol_type = molecule'
Defensive patterns
Strategy: type-guard
Validate before calling
func knownMolTypes() map[string]bool { return map[string]bool{ /* fill from types.MolType values */ } }
func validateMolTypeValue(v string) error {
if !knownMolTypes()[strings.ToLower(v)] {
return fmt.Errorf("%q is not a valid mol_type", v)
}
return nil
} Type guard
func isMolType(s string) (types.MolType, bool) {
mt := types.MolType(strings.ToLower(s))
return mt, mt.IsValid()
} Try / catch
if err != nil && strings.Contains(err.Error(), "invalid mol_type:") {
// show the list of valid mol_type literals to the user
} Prevention
- Use types.MolType constants instead of hand-typed literals.
- Validate with MolType.IsValid() before building the query string.
- Case is forgiving (lowered) but spelling must be exact — copy literals from docs.
When it happens
Trigger: Queries like `mol_type = mol`, `mol_type = MOLcule` is fine after lowering but `mol_type = moleculee` or `mol_type = epic` fail validity.
Common situations: Typos in type names; guessing type literals instead of using documented values; scripts passing user input directly into the query.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid mode '%s', must be 'compile' or 'runtime'
- invalid --waits-for-gate value %q (valid: all-children, any-
- invalid started time: %w
- invalid boolean value for %s: %s
- %q is not a sweep tier; use %q or %q
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/ea007adc77fb8d72.
Report an issue: GitHub.