{"record":{"id":"d75ea8dc2daa02ab","repo":"vxcontrol/pentagi","slug":"flow-d-is-in-unknown-status-s","errorCode":null,"errorMessage":"flow %d is in unknown status: %s","messagePattern":"flow (.+?) is in unknown status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/controller/flows.go","lineNumber":295,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\t} else if fw, ok = fc.flows[flowID]; ok {\n\t\tstatus, err := fw.GetStatus(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to get flow %d status: %w\", flowID, err)\n\t\t}\n\n\t\tswitch status {\n\t\tcase database.FlowStatusCreated:\n\t\t\treturn nil, fmt.Errorf(\"flow %d is not completed\", flowID)\n\t\tcase database.FlowStatusFinished, database.FlowStatusFailed:\n\t\t\tif err := loadFlow(); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase database.FlowStatusRunning, database.FlowStatusWaiting:\n\t\t\tbreak\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"flow %d is in unknown status: %s\", flowID, status)\n\t\t}\n\t} else {\n\t\tif err := loadFlow(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif fw == nil { // just double check, this should never happen\n\t\treturn nil, fmt.Errorf(\"unexpected error: flow %d not found\", flowID)\n\t}\n\n\taw, err := NewAssistantWorker(ctx, newAssistantWorkerCtx{\n\t\tuserID:        userID,\n\t\tflowID:        flowID,\n\t\tinput:         input,\n\t\tprvname:       prvname,\n\t\tprvtype:       prvtype,\n\t\tuseAgents:     useAgents,","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/controller/flows.go#L277-L313","documentation":"Returned by CreateAssistant when the flow's status is not one of the recognized values (Created, Finished, Failed, Running, Waiting). Since all known FlowStatus enum values are handled, this indicates corrupt or out-of-range status data in the database.","triggerScenarios":"CreateAssistant reads fw.GetStatus and the returned status string matches no case — e.g. a manually edited DB row, a migration that introduced a new enum value the code doesn't know, or binary corruption of the status column.","commonSituations":"Hand-editing flow status in PostgreSQL, running a newer/older schema than the application binary expects, or data imported from a different version of PentAGI.","solutions":["Inspect the flow row's status value in the database and normalize it to a valid enum value.","Align the application binary and migrations to the same version so the status enum matches.","Manually update the row to FlowStatusFailed or FlowStatusWaiting so loadFlow can reset it.","Restore the row from a backup if the data is corrupted."],"exampleFix":"// before\nUPDATE flows SET status='pending' WHERE id=42; -- unknown value\n// after\nUPDATE flows SET status='waiting' WHERE id=42;","handlingStrategy":"validation","validationCode":"// sanitize status stored outside the app\nSELECT id, status FROM flows WHERE status NOT IN\n  ('created','running','finished','failed','waiting');","typeGuard":"func isKnownFlowStatus(s string) bool {\n    switch s {\n    case \"created\", \"running\", \"finished\", \"failed\", \"waiting\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"if _, err := ctl.CreateAssistant(...); err != nil {\n    if strings.Contains(err.Error(), \"unknown status\") {\n        // fix the row or restore from backup, then retry\n    }\n}","preventionTips":["Never hand-edit flow status values in the database.","Keep binary and migrations on the same version.","Constrain the status column to the enum via DB constraints."],"tags":["go","flow-status","data-corruption","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}