vxcontrol/pentagi · error

flow not found

Error message

flow not found

What it means

GetFlowToolCallLog looks up the per-flow FlowToolCallLogWorker in an in-memory map keyed by flowID. This error means no worker has been registered for that flow ID — it is a pure lookup miss, not a database error. The worker is created when a flow is instantiated, so asking before creation (or after process restart / flow removal) yields this error.

Source

Thrown at backend/pkg/controller/tclogs.go:67

	flows := make([]FlowToolCallLogWorker, 0, len(c.flows))
	for _, flw := range c.flows {
		flows = append(flows, flw)
	}

	return flows, nil
}

func (c *toolCallLogController) GetFlowToolCallLog(
	ctx context.Context,
	flowID int64,
) (FlowToolCallLogWorker, error) {
	c.mx.Lock()
	defer c.mx.Unlock()

	flw, ok := c.flows[flowID]
	if !ok {
		return nil, fmt.Errorf("flow not found")
	}

	return flw, nil
}

View on GitHub (pinned to ea665308ba)

Solutions

  1. Verify the flow exists and was created through the normal flow-creation API before querying its log worker
  2. Check errors.Is equivalent (string match "flow not found") and map to 404 in handlers
  3. Re-query the flow list instead of reusing cached flow IDs after restarts
  4. If running multiple instances, ensure requests are routed to the node owning the flow (or persist worker state externally)
  5. Create the worker via the controller's flow-registration path if you legitimately need one

Example fix

// before
worker, err := ctl.GetFlowToolCallLog(ctx, flowID) // panics downstream on nil use
if err != nil { return err } // treated as 500
// after
worker, err := ctl.GetFlowToolCallLog(ctx, flowID)
if err != nil && strings.Contains(err.Error(), "flow not found") {
    return graphql.ErrorNotFound // or HTTP 404
}
Defensive patterns

Strategy: type-guard

Validate before calling

func flowKnown(flowID int64, knownFlows map[int64]struct{}) bool {
    _, ok := knownFlows[flowID]
    return ok
}

Type guard

func isFlowNotFound(err error) bool {
    return err != nil && strings.Contains(err.Error(), "flow not found")
}

Try / catch

worker, err := ctl.GetFlowToolCallLog(ctx, flowID)
if isFlowNotFound(err) {
    return nil, httpErr(http.StatusNotFound, "flow %d not found", flowID)
}
if err != nil {
    return nil, err
}

Prevention

When it happens

Trigger: Calling GetFlowToolCallLog with a flowID that was never created, a flow already finished/removed from the map, or after a backend restart while clients still hold old flow IDs.

Common situations: Stale IDs in a frontend after server redeploy; racing a flow-creation request with tool-call queries; querying flows created by another instance in multi-node deployments.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/ecb397c055c166bd. Report an issue: GitHub.