Skip to main content

Fix: conversation_artifacts missing for run_analysis_artifact

Summary​

Resolved run_analysis_artifact failures caused by relation "conversation_artifacts" does not exist.

What changed​

  1. Applied the required database migration directly:
    • services/backend/src/db/migrations/0034_conversation_artifacts_analysis_workflow.sql
    • services/backend/src/db/migrations/0039_web_search_cache_knowledge_base.sql (kept schema in expected shape for related artifact/caching flows)
  2. Added backend guardrails in services/backend/src/routes/bots/bots-chat-handlers.ts:
    • listConversationArtifacts(...) now catches PostgreSQL undefined_table (42P01) for conversation_artifacts and returns an empty list with a warning instead of crashing the chat flow.
    • loadCodeArtifact(...) now catches the same condition and throws an actionable error message instructing to run migration 0034_conversation_artifacts_analysis_workflow.sql.
    • Added isPgUndefinedTableError(...) helper to centralize this check.

Why​

The runtime code expects conversation_artifacts to exist for loading/saving analysis artifacts. If a target Neon environment misses migration 0034, run_analysis_artifact fails with a raw SQL error. This change fixes current schema drift and improves resilience if drift reappears.

Validation​

  • Ran migration command path in project root and confirmed table exists.
  • Verified relation:
SELECT to_regclass('public.conversation_artifacts');
-- conversation_artifacts
  • Ran repository checks:
    • pnpm typecheck
    • pnpm lint

Both completed successfully with existing non-blocking warnings (no new errors introduced by this change).

Notes​

  • Full migration runner (pnpm migrate:neon) currently stops at an older non-idempotent migration (0007_exchange_credentials_and_orders.sql) in this environment due to relation "exchange_credentials" already exists.
  • Applied targeted migrations to unblock the production issue immediately.