{"record":{"id":"9e350e749b46be6b","repo":"plandex-ai/plandex","slug":"failed-to-store-assistant-message-v","errorCode":null,"errorMessage":"failed to store assistant message: %v","messagePattern":"failed to store assistant message: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/plan/tell_stream_store.go","lineNumber":148,"sourceCode":"\t\tif hasNewSubtasks && (state.req.IsApplyDebug || state.req.IsUserDebug) {\n\t\t\tlog.Println(\"storeOnFinished: hasNewSubtasks && (state.req.IsApplyDebug || state.req.IsUserDebug)\")\n\t\t\tflags.DidMakeDebuggingPlan = true\n\t\t}\n\n\t\tlog.Println(\"storeOnFinished: flags\", flags)\n\n\t\tassistantMsg, convoCommitMsg, err := state.storeAssistantReply(repo, storeAssistantReplyParams{\n\t\t\tflags:                flags,\n\t\t\tsubtask:              messageSubtask,\n\t\t\taddedSubtasks:        addedSubtasks,\n\t\t\tactivatePaths:        autoLoadContextResult.activatePaths,\n\t\t\tactivatePathsOrdered: autoLoadContextResult.activatePathsOrdered,\n\t\t\tremovedSubtasks:      removedSubtasks,\n\t\t}) // updates state.convo\n\n\t\tif err != nil {\n\t\t\tstate.onError(onErrorParams{\n\t\t\t\tstreamErr: fmt.Errorf(\"failed to store assistant message: %v\", err),\n\t\t\t\tstoreDesc: true,\n\t\t\t})\n\t\t\treturn err\n\t\t}\n\n\t\tlog.Println(\"getting description for assistant message: \", assistantMsg.Id)\n\n\t\tvar description *db.ConvoMessageDescription\n\t\tif len(replyOperations) == 0 {\n\t\t\tdescription = &db.ConvoMessageDescription{\n\t\t\t\tOrgId:                 currentOrgId,\n\t\t\t\tPlanId:                planId,\n\t\t\t\tConvoMessageId:        assistantMsg.Id,\n\t\t\t\tSummarizedToMessageId: summarizedToMessageId,\n\t\t\t\tBuildPathsInvalidated: map[string]bool{},\n\t\t\t\tWroteFiles:            false,\n\t\t\t}\n\t\t} else {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/tell_stream_store.go#L130-L166","documentation":"Raised while persisting the assistant message after a successful stream: after storing the conversation via the auto-loaded context (activatePathsOrdered, removedSubtasks), the returned err indicates the assistant message could not be stored. The error is reported through state.onError with storeDesc:true and then returned, aborting the store phase of the stream finalization even though the model output itself was generated.","triggerScenarios":"db layer fails while writing the assistant message row: database file locked/corrupt, disk full, migration mismatch, or the store call after updating state.convo returns a non-nil error (constraint violation on message fields, oversized payload).","commonSituations":"SQLite database locked by another process (a second client/editor instance open on the same project); read-only or full disk; schema migration out of date after a version upgrade; very large assistant reply exceeding storage limits.","solutions":["Check the wrapped %v cause: fix the underlying db error (unlock/close other processes, free disk space).","Run any pending database migrations for the app version.","Retry the session/tell request once the database is writable.","Back up and repair/recreate a corrupt conversation database if corruption is reported.","If caused by oversized payloads, trim conversation content before storage."],"exampleFix":"// before\nif err != nil {\n    state.onError(onErrorParams{streamErr: fmt.Errorf(\"failed to store assistant message: %v\", err), storeDesc: true})\n    return err\n}\n// after: retry transient store failures before giving up\nif err != nil {\n    if retryErr := retryDbStore(func() error { return db.StoreConvoMessage(assistantMsg) }, 3); retryErr != nil {\n        state.onError(onErrorParams{streamErr: fmt.Errorf(\"failed to store assistant message: %v\", retryErr), storeDesc: true})\n        return retryErr\n    }\n}","handlingStrategy":"try-catch","validationCode":"// before storing: ensure the DB is writable\nfunc ensureDbWritable(db *sql.DB) error {\n    if err := db.Ping(); err != nil { return err }\n    _, err := db.Exec(\"PRAGMA quick_check;\")\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := storeAssistantMessage(assistantMsg); err != nil {\n    state.onError(onErrorParams{streamErr: fmt.Errorf(\"failed to store assistant message: %v\", err), storeDesc: true})\n    return fmt.Errorf(\"store assistant message %s: %w\", assistantMsg.Id, err)\n}","preventionTips":["Close other app instances that hold the SQLite lock during sessions","Monitor disk space where the conversation DB lives","Run schema migrations on startup before accepting requests","Back up the conversation DB regularly and verify integrity"],"tags":["database","persistence","storage"],"backgroundTag":"database-write-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}