vxcontrol/pentagi · error
unexpected error: flow %d not found
Error message
unexpected error: flow %d not found
What it means
A defensive double-check in CreateAssistant: after all branches (newFlow/loadFlow/map hit), fw must be non-nil. Returning this error means an internal invariant was violated — the control flow produced no worker even though no error path was taken. The code itself notes this should never happen.
Source
Thrown at backend/pkg/controller/flows.go:304
case database.FlowStatusCreated:
return nil, fmt.Errorf("flow %d is not completed", flowID)
case database.FlowStatusFinished, database.FlowStatusFailed:
if err := loadFlow(); err != nil {
return nil, err
}
case database.FlowStatusRunning, database.FlowStatusWaiting:
break
default:
return nil, fmt.Errorf("flow %d is in unknown status: %s", flowID, status)
}
} else {
if err := loadFlow(); err != nil {
return nil, err
}
}
if fw == nil { // just double check, this should never happen
return nil, fmt.Errorf("unexpected error: flow %d not found", flowID)
}
aw, err := NewAssistantWorker(ctx, newAssistantWorkerCtx{
userID: userID,
flowID: flowID,
input: input,
prvname: prvname,
prvtype: prvtype,
useAgents: useAgents,
functions: functions,
resources: resources,
fw: fw,
flowWorkerCtx: flowWorkerCtx,
})
if err != nil {
return nil, fmt.Errorf("failed to create assistant: %w", err)
}
View on GitHub (pinned to ea665308ba)
Solutions
- Treat as an internal bug: report it with backend logs and the flowID.
- Audit recent modifications to CreateAssistant for a branch that leaves fw unset.
- Ensure nothing inserts nil FlowWorker values into fc.flows.
- Restart the backend to clear any corrupt in-memory map state.
Defensive patterns
Strategy: try-catch
Try / catch
if _, err := ctl.CreateAssistant(...); err != nil {
if strings.Contains(err.Error(), "unexpected error: flow") {
log.Error("internal invariant violated; report with logs")
}
return err
} Prevention
- Don't modify CreateAssistant control flow without preserving the fw-nil invariant.
- Never insert nil FlowWorker values into the flows map.
- Report occurrences as bugs with full logs and flowID.
When it happens
Trigger: Only via an internal bug: a branch that neither sets fw nor returns an error (e.g. future code changes adding a status case that falls through, or fc.flows returning a nil-valued entry for an existing key).
Common situations: Practically never in normal operation; may appear after custom modifications to CreateAssistant or if the flows map was populated with nil workers by other code paths.
Related errors
- bearer scheme must be used
- token can't be empty
- token validation disabled with default salt
- token is invalid
- token not found in database
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/d1c637b1a21502d2.
Report an issue: GitHub.