fix(report): stop listing reports via PostgREST JSON paths (BUG-574)

Staging PostgREST rejects the executiveSummary JSON-path alias, so GET /api/reports 500s. Persist a plain card_summary column from the Markdown excerpt instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-07 11:08:00 +08:00
co-authored by Cursor
parent ad9283d1bd
commit b466a6fc8c
15 changed files with 517 additions and 10 deletions
+3 -2
View File
@@ -28,6 +28,7 @@ import { loadReportCandidateRange } from "@/lib/report-candidate-range";
import { createAdminSupabaseClient } from "@/lib/supabase/admin";
import { authorizeUsage, completeUsage, releaseUsage } from "@/lib/consultation-billing";
import { FeaturePricingError, resolveFeaturePricing } from "@/lib/feature-pricing";
import { sanitizedErrorReason } from "@/lib/safe-error-reason";
import { isSupabaseConfigurationError } from "@/lib/supabase/config";
import { createServerSupabaseClient } from "@/lib/supabase/server";
@@ -45,7 +46,7 @@ const REPORT_LIST_COLUMNS = [
"failure_code",
"created_at",
"completed_at",
"card_summary:report_document->executiveSummary->>summary",
"card_summary",
].join(",");
function sanitizedErrorCode(error: unknown): string {
@@ -139,7 +140,7 @@ export async function GET() {
{ status: 503 },
);
}
console.error(`[reports] list failed reason=${sanitizedErrorCode(error)}`);
console.error(`[reports] list failed reason=${sanitizedErrorReason(error)}`);
return NextResponse.json(
{ error: "报告列表暂时无法读取", code: REPORT_STABLE_CODES.generationFailed },
{ status: 500 },