{"record":{"id":"ea007adc77fb8d72","repo":"gastownhall/beads","slug":"invalid-mol-type-s","errorCode":null,"errorMessage":"invalid mol_type: %s","messagePattern":"invalid mol_type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/query/evaluator.go","lineNumber":493,"sourceCode":"\n\tswitch field {\n\tcase \"pinned\":\n\t\tfilter.Pinned = &boolVal\n\tcase \"ephemeral\":\n\t\tfilter.Ephemeral = &boolVal\n\tcase \"template\":\n\t\tfilter.IsTemplate = &boolVal\n\t}\n\treturn nil\n}\n\nfunc (e *Evaluator) applyMolTypeFilter(comp *ComparisonNode, filter *types.IssueFilter) error {\n\tif comp.Op != OpEquals {\n\t\treturn fmt.Errorf(\"mol_type only supports = operator\")\n\t}\n\tmt := types.MolType(strings.ToLower(comp.Value))\n\tif !mt.IsValid() {\n\t\treturn fmt.Errorf(\"invalid mol_type: %s\", comp.Value)\n\t}\n\tfilter.MolType = &mt\n\treturn nil\n}\n\n// applyMetadataFilter handles metadata.<key>=<value> queries (GH#1406).\nfunc (e *Evaluator) applyMetadataFilter(comp *ComparisonNode, filter *types.IssueFilter) error {\n\tif comp.Op != OpEquals {\n\t\treturn fmt.Errorf(\"metadata fields only support = operator\")\n\t}\n\tkey := strings.TrimPrefix(comp.Field, \"metadata.\")\n\tif err := storage.ValidateMetadataKey(key); err != nil {\n\t\treturn err\n\t}\n\tif filter.MetadataFields == nil {\n\t\tfilter.MetadataFields = make(map[string]string)\n\t}\n\tfilter.MetadataFields[key] = comp.Value","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/query/evaluator.go#L475-L511","documentation":"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.","triggerScenarios":"Queries like `mol_type = mol`, `mol_type = MOLcule` is fine after lowering but `mol_type = moleculee` or `mol_type = epic` fail validity.","commonSituations":"Typos in type names; guessing type literals instead of using documented values; scripts passing user input directly into the query.","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."],"exampleFix":"// before\nbd list 'mol_type = moleculee'\n// after\nbd list 'mol_type = molecule'","handlingStrategy":"type-guard","validationCode":"func knownMolTypes() map[string]bool { return map[string]bool{ /* fill from types.MolType values */ } }\nfunc validateMolTypeValue(v string) error {\n\tif !knownMolTypes()[strings.ToLower(v)] {\n\t\treturn fmt.Errorf(\"%q is not a valid mol_type\", v)\n\t}\n\treturn nil\n}","typeGuard":"func isMolType(s string) (types.MolType, bool) {\n\tmt := types.MolType(strings.ToLower(s))\n\treturn mt, mt.IsValid()\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid mol_type:\") {\n\t// show the list of valid mol_type literals to the user\n}","preventionTips":["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."],"tags":["query-language","validation","enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}