{"record":{"id":"9cf9db26746288b8","repo":"gastownhall/beads","slug":"unknown-condition-type-s","errorCode":null,"errorMessage":"unknown condition type: %s","messagePattern":"unknown condition type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/formula/condition.go","lineNumber":241,"sourceCode":"\t\t\tOperator: Operator(m[2]),\n\t\t\tValue:    unquote(m[3]),\n\t\t}, nil\n\t}\n\n\treturn nil, fmt.Errorf(\"unrecognized condition format: %s\", expr)\n}\n\n// Evaluate evaluates the condition against the given context.\nfunc (c *Condition) Evaluate(ctx *ConditionContext) (*ConditionResult, error) {\n\tswitch c.Type {\n\tcase ConditionTypeField:\n\t\treturn c.evaluateField(ctx)\n\tcase ConditionTypeAggregate:\n\t\treturn c.evaluateAggregate(ctx)\n\tcase ConditionTypeExternal:\n\t\treturn c.evaluateExternal(ctx)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown condition type: %s\", c.Type)\n\t}\n}\n\nfunc (c *Condition) evaluateField(ctx *ConditionContext) (*ConditionResult, error) {\n\t// Resolve step reference\n\tstepID := c.StepRef\n\tif stepID == \"step\" {\n\t\tstepID = ctx.CurrentStep\n\t}\n\n\tstep, ok := ctx.Steps[stepID]\n\tif !ok {\n\t\treturn &ConditionResult{\n\t\t\tSatisfied: false,\n\t\t\tReason:    fmt.Sprintf(\"step %q not found\", stepID),\n\t\t}, nil\n\t}\n","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/formula/condition.go#L223-L259","documentation":"Condition.Evaluate dispatches on the Condition.Type field; if Type is not one of the three supported kinds (field, aggregate, external), evaluation fails with this error. The library only produces a Condition via ParseCondition, which always sets a valid Type, so this only fires when a Condition struct is constructed programmatically with a zero-value or invalid Type.","triggerScenarios":"Calling Condition.Evaluate (or EvaluateCondition on a hand-built Condition) where Condition.Type is \"\" or an arbitrary string — e.g. `&formula.Condition{Field: \"status\", Operator: formula.OpEqual, Value: \"complete\"}` without setting Type.","commonSituations":"Building a Condition manually instead of via ParseCondition; forgetting to set Type after copying fields; custom code that constructs conditions from config data without mapping the type string to ConditionTypeField/Aggregate/External.","solutions":["Set Condition.Type explicitly to ConditionTypeField, ConditionTypeAggregate, or ConditionTypeExternal when constructing the struct","Prefer building conditions with formula.ParseCondition(expr), which always assigns a valid Type","Validate Type before calling Evaluate: switch on c.Type and reject anything outside the three constants"],"exampleFix":"// before\ncond := &formula.Condition{StepRef: \"review\", Field: \"status\", Operator: formula.OpEqual, Value: \"complete\"}\nres, err := cond.Evaluate(ctx) // unknown condition type:\n// after\ncond, err := formula.ParseCondition(\"review.status == 'complete'\")\nres, err := cond.Evaluate(ctx)","handlingStrategy":"validation","validationCode":"func validConditionType(c *formula.Condition) bool {\n\tswitch c.Type {\n\tcase formula.ConditionTypeField, formula.ConditionTypeAggregate, formula.ConditionTypeExternal:\n\t\treturn true\n\t}\n\treturn false\n}\nif !validConditionType(cond) { return fmt.Errorf(\"condition type %q not supported\", cond.Type) }","typeGuard":"func isKnownConditionType(t formula.ConditionType) bool {\n\treturn t == formula.ConditionTypeField || t == formula.ConditionTypeAggregate || t == formula.ConditionTypeExternal\n}","tryCatchPattern":"res, err := cond.Evaluate(ctx)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"unknown condition type\") {\n\t\treturn fmt.Errorf(\"condition misconfigured (type=%q): build via formula.ParseCondition\", cond.Type)\n\t}\n\treturn err\n}","preventionTips":["Always construct conditions with formula.ParseCondition, never raw struct literals","Check Type against the exported ConditionType constants before Evaluate","Add a unit test round-tripping every condition string through ParseCondition"],"tags":["formula","condition-evaluation","programming-error"],"backgroundTag":"invalid-enum-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}