vxcontrol/pentagi · error

failed to get flow msg log: %w

Error message

failed to get flow msg log: %w

What it means

This error wraps a failure from cnts.mlc.GetFlowMsgLog(ctx, flowID), the message-log provider worker lookup for a flow, when assembling the flowProviderWorkers bundle in the flow controller. It is a %w-wrapped error, so the underlying cause (typically a database or gRPC failure) is preserved and can be inspected with errors.Is/As. The controller aborts the whole flow-load operation when any single log stream cannot be retrieved.

Source

Thrown at backend/pkg/controller/flow.go:1225

		vslw: vslw,
		tclw: tclw,
		sw:   sw,
	}, nil
}

func getFlowProviderWorkers(
	ctx context.Context,
	flowID int64,
	cnts *flowProviderControllers,
) (*flowProviderWorkers, error) {
	alw, err := cnts.alc.GetFlowAgentLog(ctx, flowID)
	if err != nil {
		return nil, fmt.Errorf("failed to get flow agent log: %w", err)
	}

	mlw, err := cnts.mlc.GetFlowMsgLog(ctx, flowID)
	if err != nil {
		return nil, fmt.Errorf("failed to get flow msg log: %w", err)
	}

	slw, err := cnts.slc.GetFlowSearchLog(ctx, flowID)
	if err != nil {
		return nil, fmt.Errorf("failed to get flow search log: %w", err)
	}

	tlw, err := cnts.tlc.GetFlowTermLog(ctx, flowID)
	if err != nil {
		return nil, fmt.Errorf("failed to get flow term log: %w", err)
	}

	vslw, err := cnts.vslc.GetFlowVectorStoreLog(ctx, flowID)
	if err != nil {
		return nil, fmt.Errorf("failed to get flow vector store log: %w", err)
	}

	tclw, err := cnts.tclc.GetFlowToolCallLog(ctx, flowID)

View on GitHub (pinned to ea665308ba)

Solutions

  1. Check the wrapped cause (%w chain) — it is almost always a DB error; verify PostgreSQL connectivity and logs.
  2. Verify the flowID exists (query the flows table) before fetching logs.
  3. Confirm DB migrations are up to date (goose) so msg-log tables exist.
  4. Retry the request if the cause is a transient connection/timeout error.

Example fix

// before
mlw, err := cnts.mlc.GetFlowMsgLog(ctx, flowID)
if err != nil {
	return nil, fmt.Errorf("failed to get flow msg log: %w", err)
}
// after
mlw, err := cnts.mlc.GetFlowMsgLog(ctx, flowID)
if err != nil {
	if errors.Is(err, database.ErrNotFound) {
		return nil, fmt.Errorf("flow %d has no msg log: %w", flowID, err)
	}
	return nil, fmt.Errorf("failed to get flow msg log: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

var exists bool
err := db.QueryRow("SELECT EXISTS(SELECT 1 FROM flows WHERE id=$1)", flowID).Scan(&exists)
if err != nil || !exists { /* skip fetch or surface 404 */ }

Type guard

func isMsgLogError(err error) bool {
	return err != nil && strings.Contains(err.Error(), "failed to get flow msg log")
}

Try / catch

mlw, err := cnts.mlc.GetFlowMsgLog(ctx, flowID)
if err != nil {
	var retryable *db.RetryableError
	if errors.As(err, &retryable) { /* retry with backoff */ }
	return nil, fmt.Errorf("failed to get flow msg log: %w", err)
}

Prevention

When it happens

Trigger: Calling the flow detail/export path that builds flowProviderWorkers when the msg-log component cannot fetch logs for the given flowID: flowID does not exist, the DB row/query fails, or the underlying message-log service errors.

Common situations: Requesting logs for a deleted flow; PostgreSQL connection pool exhaustion or timeout; schema/migration drift between app version and DB; passing a flowID from a different environment/database.

Related errors


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