{"record":{"id":"c72bde31f4bf5a10","repo":"vxcontrol/pentagi","slug":"failed-to-create-flow-screenshot-w","errorCode":null,"errorMessage":"failed to create flow screenshot: %w","messagePattern":"failed to create flow screenshot: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/controller/flow.go","lineNumber":1199,"sourceCode":"\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)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create flow screenshot: %w\", err)\n\t}\n\n\treturn &flowProviderWorkers{\n\t\tmlw:  mlw,\n\t\talw:  alw,\n\t\tslw:  slw,\n\t\ttlw:  tlw,\n\t\tvslw: vslw,\n\t\ttclw: tclw,\n\t\tsw:   sw,\n\t}, nil\n}\n\nfunc getFlowProviderWorkers(\n\tctx context.Context,\n\tflowID int64,\n\tcnts *flowProviderControllers,\n) (*flowProviderWorkers, error) {","sourceCodeStart":1181,"sourceCodeEnd":1217,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/controller/flow.go#L1181-L1217","documentation":"Final step of newFlowProviderWorkers: the screenshot worker is created via cnts.sc.NewFlowScreenshot(ctx, flowID, pub). Failure wrapped with this message aborts flow startup — screenshots captured by browser tooling could not be wired to persistent storage for this flow.","triggerScenarios":"NewFlowScreenshot fails during flow startup — DB error initializing the screenshot storage record for the flow, invalid flowID, or context cancellation after all earlier worker steps.","commonSituations":"DB outage or pool exhaustion at flow creation; screenshot storage table/blob path misconfigured or missing; flow deleted concurrently; ctx deadline exceeded due to slow earlier steps.","solutions":["Check the wrapped error and backend logs for the storage/DB failure","Verify the screenshot storage backend configuration and that its table/bucket exists","Confirm DB connectivity and retry flow creation","Ensure the flow row exists (rule out concurrent deletion)"],"exampleFix":"// before: screenshot storage path not validated at startup\nsw, err := cnts.sc.NewFlowScreenshot(ctx, flowID, pub)\nif err != nil { return nil, fmt.Errorf(\"failed to create flow screenshot: %w\", err) }\n// after: pre-validate storage dir/config before creating workers\nif err := ensureScreenshotStorage(ctx, cfg); err != nil {\n    return nil, fmt.Errorf(\"screenshot storage unavailable: %w\", err)\n}\nsw, err = cnts.sc.NewFlowScreenshot(ctx, flowID, pub)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create flow screenshot (flow=%d): %w\", flowID, err)\n}","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(cfg.ScreenshotStoragePath); err != nil || !fi.IsDir() {\n    return errors.New(\"screenshot storage path missing or not a directory\")\n}","typeGuard":"func hasValidFlowID(flowID int64) bool { return flowID > 0 }","tryCatchPattern":"sw, err := cnts.sc.NewFlowScreenshot(ctx, flowID, pub)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create flow screenshot (flow=%d): %w\", flowID, err)\n}","preventionTips":["Validate screenshot storage config (path/table) at application boot, not per-flow","Keep DB migrations current so the screenshot storage table exists","Check disk space/permissions on the storage volume","Confirm flow existence before the final worker-creation step"],"tags":["go","database","flow-startup","screenshots"],"backgroundTag":"database-write-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}