vxcontrol/pentagi · error

flow not found

Error message

flow not found

What it means

GetFlowVectorStoreLog (the controller's factory/lookup) retrieves the per-flow FlowVectorStoreLogWorker from the vslc.flows map under a mutex. If no worker is registered for the given flowID it returns "flow not found". Like error 210, this reflects missing in-memory registration rather than a database lookup.

Source

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

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

	return flows, nil
}

func (vslc *vectorStoreLogController) GetFlowVectorStoreLog(
	ctx context.Context,
	flowID int64,
) (FlowVectorStoreLogWorker, error) {
	vslc.mx.Lock()
	defer vslc.mx.Unlock()

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

	return flw, nil
}

View on GitHub (pinned to ea665308ba)

Solutions

  1. Validate the flow ID is an active flow before requesting its vector-store log worker.
  2. Re-register/rebuild the flow worker lazily when the flow exists in the DB but not in memory.
  3. Return a typed sentinel (ErrFlowNotFound) so callers can distinguish not-found from internal errors.
  4. For flows that must be inspectable post-restart, read logs directly from the DB instead of requiring the in-memory worker.

Example fix

// before
worker, err := vslc.GetFlowVectorStoreLog(ctx, flowID, pub)
if err != nil { return err }
// after
worker, err := vslc.GetFlowVectorStoreLog(ctx, flowID, pub)
if err != nil {
    if errors.Is(err, ErrFlowNotFound) {
        // flow finished or server restarted: query logs directly from DB
        return vslc.db.GetFlowVectorStoreLogs(ctx, flowID)
    }
    return err
}
Defensive patterns

Strategy: fallback

Validate before calling

if flowID <= 0 {
    return fmt.Errorf("invalid flow id %d", flowID)
}
active, _ := isFlowActive(ctx, flowID)
if !active {
    // read logs directly from DB instead of requesting the in-memory worker
    return readVectorStoreLogsFromDB(ctx, flowID)
}

Type guard

func isControllerFlowNotFound(err error) bool {
    return errors.Is(err, ErrFlowNotFound) // after introducing the sentinel
}

Try / catch

worker, err := vslc.GetFlowVectorStoreLog(ctx, flowID, pub)
if err != nil {
    if errors.Is(err, ErrFlowNotFound) {
        return fallbackDBLogReader(ctx, flowID) // finished flow or restart
    }
    return err
}

Prevention

When it happens

Trigger: Calling the controller's GetFlowVectorStoreLog(ctx, flowID, ...) for a flow whose worker was never created (NewFlowVectorStoreLogWorker + registration never ran), was de-registered on flow completion/deletion, or after a process restart.

Common situations: Resuming or inspecting a finished flow after server restart; a GraphQL resolver serving a stale flow ID from a saved UI session; concurrent delete of the flow racing with a log fetch.

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/aaf1e6ba05def1db. Report an issue: GitHub.