{"record":{"id":"c20aa2792811f0a0","repo":"vxcontrol/pentagi","slug":"failed-to-create-flow-search-log-w","errorCode":null,"errorMessage":"failed to create flow search log: %w","messagePattern":"failed to create flow search log: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/controller/flow.go","lineNumber":1179,"sourceCode":"func newFlowProviderWorkers(\n\tctx context.Context,\n\tflowID int64,\n\tcnts *flowProviderControllers,\n\tpub subscriptions.FlowPublisher,\n) (*flowProviderWorkers, error) {\n\talw, err := cnts.alc.NewFlowAgentLog(ctx, flowID, pub)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow agent log: %w\", err)\n\t}\n\n\tmlw, err := cnts.mlc.NewFlowMsgLog(ctx, flowID, pub)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow msg log: %w\", err)\n\t}\n\n\tslw, err := cnts.slc.NewFlowSearchLog(ctx, flowID, pub)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow search log: %w\", err)\n\t}\n\n\ttlw, err := cnts.tlc.NewFlowTermLog(ctx, flowID, pub)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow term log: %w\", err)\n\t}\n\n\tvslw, err := cnts.vslc.NewFlowVectorStoreLog(ctx, flowID, pub)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow vector store log: %w\", err)\n\t}\n\n\ttclw, err := cnts.tclc.NewFlowToolCallLog(ctx, flowID, pub)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow tool call log: %w\", err)\n\t}\n\n\tsw, err := cnts.sc.NewFlowScreenshot(ctx, flowID, pub)","sourceCodeStart":1161,"sourceCodeEnd":1197,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/controller/flow.go#L1161-L1197","documentation":"Third step of newFlowProviderWorkers: the search log worker is created via cnts.slc.NewFlowSearchLog(ctx, flowID, pub). Failure is wrapped with this message and aborts flow startup — the platform refuses to run a flow that cannot record web-search tool results.","triggerScenarios":"NewFlowSearchLog fails during flow startup: DB error on the search-log storage for this flow, invalid/deleted flowID, or context cancelled by the time this step runs.","commonSituations":"Postgres outage or pool exhaustion mid-startup; search_logs table locked or missing (skipped migration); flow deleted between earlier worker-creation steps; long transaction backlog causing ctx deadline.","solutions":["Inspect the wrapped error and Postgres logs for the failing statement","Verify search_logs schema exists (run goose migrations)","Confirm DB connectivity, then retry flow creation","Check whether the flow row was deleted concurrently"],"exampleFix":"// before: opaque wrap without flow context\nslw, err := cnts.slc.NewFlowSearchLog(ctx, flowID, pub)\nif err != nil { return nil, fmt.Errorf(\"failed to create flow search log: %w\", err) }\n// after: include flowID and require migrations up-to-date beforehand\nif err := migrationsUpToDate(ctx, db); err != nil { return nil, err }\nslw, err := cnts.slc.NewFlowSearchLog(ctx, flowID, pub)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create flow search log (flow=%d): %w\", flowID, err)\n}","handlingStrategy":"retry","validationCode":"var t int\nif err := db.QueryRowContext(ctx, `SELECT COUNT(1) FROM information_schema.tables WHERE table_name='search_logs'`).Scan(&t); err != nil || t == 0 {\n    return errors.New(\"search_logs table missing: run migrations\")\n}","typeGuard":"func hasValidFlowID(flowID int64) bool { return flowID > 0 }","tryCatchPattern":"slw, err := cnts.slc.NewFlowSearchLog(ctx, flowID, pub)\nif err != nil {\n    if isTransientDBError(err) { /* retry with backoff */ }\n    return nil, fmt.Errorf(\"failed to create flow search log (flow=%d): %w\", flowID, err)\n}","preventionTips":["Never skip migrations when upgrading","Monitor search_logs table size/locks","Check for concurrent flow deletion before worker creation","Give each startup step a fresh deadline to avoid inherited timeouts"],"tags":["go","database","flow-startup","search-logs"],"backgroundTag":"database-write-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}