From 3abd4ab804e7d7e8865714130b665911a155fbf0 Mon Sep 17 00:00:00 2001 From: David Santos Date: Wed, 25 Nov 2026 12:18:20 +0000 Subject: [PATCH 1/2] =?UTF-8?q?hotfix(hub):=20preserve=20production=20drif?= =?UTF-8?q?t=20=E2=80=94=20slimContext/context=5Fdata=20+=20resolve=20endp?= =?UTF-8?q?oints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Production CT225 has uncommitted changes not in master: - recentErrors.ts: add slimContext() to trim large context_data blobs and expose context_data in the recent-errors response - admin-ui resolve-by-pattern/route.ts: new endpoint - admin-ui resolve-fixed-patterns/route.ts: new endpoint This commit preserves the drift so it can be PR-reviewed and merged over 7bc04e8 (PR20). Paperclip-Issue: BIT-33338 --- .../resolve-by-pattern/route.ts | 47 +++++++++++++++++++ .../resolve-fixed-patterns/route.ts | 47 +++++++++++++++++++ api/src/routes/public/recentErrors.ts | 25 ++++++++++ 3 files changed, 119 insertions(+) create mode 100644 admin-ui/app/api/error-monitoring/resolve-by-pattern/route.ts create mode 100644 admin-ui/app/api/error-monitoring/resolve-fixed-patterns/route.ts diff --git a/admin-ui/app/api/error-monitoring/resolve-by-pattern/route.ts b/admin-ui/app/api/error-monitoring/resolve-by-pattern/route.ts new file mode 100644 index 0000000..064b793 --- /dev/null +++ b/admin-ui/app/api/error-monitoring/resolve-by-pattern/route.ts @@ -0,0 +1,47 @@ +import type { NextRequest } from "next/server"; +import { NextResponse } from "next/server"; + +export const dynamic = "force-dynamic"; + +export async function POST(request: NextRequest) { + const rawBase = process.env.ERROR_REPORTING_ADMIN_API_BASE?.trim(); + if (!rawBase) { + return NextResponse.json( + { + success: false, + message: "ERROR_REPORTING_ADMIN_API_BASE is not configured.", + }, + { status: 503 }, + ); + } + const base = rawBase.replace(/\/$/, ""); + const target = `${base}/api/error-monitoring/resolve-by-pattern`; + const body = await request.text(); + + const headers: Record = { + Accept: "application/json", + "Content-Type": request.headers.get("Content-Type") ?? "application/json", + }; + const cookie = request.headers.get("cookie"); + if (cookie) { + headers.Cookie = cookie; + } + const resolveHdr = request.headers.get("x-error-resolve-key"); + if (resolveHdr) { + headers["X-Error-Resolve-Key"] = resolveHdr; + } + + const upstream = await fetch(target, { + method: "POST", + headers, + body: body || undefined, + cache: "no-store", + }); + + const text = await upstream.text(); + const ct = upstream.headers.get("Content-Type") ?? "application/json; charset=utf-8"; + return new NextResponse(text, { + status: upstream.status, + headers: { "Content-Type": ct }, + }); +} diff --git a/admin-ui/app/api/error-monitoring/resolve-fixed-patterns/route.ts b/admin-ui/app/api/error-monitoring/resolve-fixed-patterns/route.ts new file mode 100644 index 0000000..027e349 --- /dev/null +++ b/admin-ui/app/api/error-monitoring/resolve-fixed-patterns/route.ts @@ -0,0 +1,47 @@ +import type { NextRequest } from "next/server"; +import { NextResponse } from "next/server"; + +export const dynamic = "force-dynamic"; + +export async function POST(request: NextRequest) { + const rawBase = process.env.ERROR_REPORTING_ADMIN_API_BASE?.trim(); + if (!rawBase) { + return NextResponse.json( + { + success: false, + message: "ERROR_REPORTING_ADMIN_API_BASE is not configured.", + }, + { status: 503 }, + ); + } + const base = rawBase.replace(/\/$/, ""); + const target = `${base}/api/error-monitoring/resolve-fixed-patterns`; + const body = await request.text(); + + const headers: Record = { + Accept: "application/json", + "Content-Type": request.headers.get("Content-Type") ?? "application/json", + }; + const cookie = request.headers.get("cookie"); + if (cookie) { + headers.Cookie = cookie; + } + const resolveHdr = request.headers.get("x-error-resolve-key"); + if (resolveHdr) { + headers["X-Error-Resolve-Key"] = resolveHdr; + } + + const upstream = await fetch(target, { + method: "POST", + headers, + body: body || undefined, + cache: "no-store", + }); + + const text = await upstream.text(); + const ct = upstream.headers.get("Content-Type") ?? "application/json; charset=utf-8"; + return new NextResponse(text, { + status: upstream.status, + headers: { "Content-Type": ct }, + }); +} diff --git a/api/src/routes/public/recentErrors.ts b/api/src/routes/public/recentErrors.ts index a59b5c3..f4c2532 100644 --- a/api/src/routes/public/recentErrors.ts +++ b/api/src/routes/public/recentErrors.ts @@ -100,6 +100,29 @@ function parseStatusList(raw: string | undefined): string[] | null { return parts.length > 0 ? parts : ['open', 'investigating']; } + +function slimContext(ctx: Record | null): Record | null { + if (!ctx) return null; + const out: Record = {}; + for (const key of Object.keys(ctx).slice(0, 40)) out[key] = slimContextValue(ctx[key], 0); + return out; +} + +function slimContextValue(value: unknown, depth: number): unknown { + if (depth > 3) return '[nested]'; + if (typeof value === 'string') return value.length > 1500 ? `${value.slice(0, 1500)}…` : value; + if (value == null || typeof value === 'number' || typeof value === 'boolean') return value; + if (Array.isArray(value)) return value.slice(0, 20).map((item) => slimContextValue(item, depth + 1)); + if (typeof value === 'object') { + const nested: Record = {}; + for (const [key, item] of Object.entries(value as Record).slice(0, 30)) { + nested[key] = slimContextValue(item, depth + 1); + } + return nested; + } + return String(value).slice(0, 500); +} + async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply): Promise { const db = request.server.db; @@ -303,6 +326,8 @@ async function handleRecentErrors(request: FastifyRequest, reply: FastifyReply): if (paperclip_project_id !== '') { rowOut.paperclip_project_id = paperclip_project_id; } + const contextData = slimContext(ctx); + if (contextData) rowOut.context_data = contextData; return rowOut; }); From 6a55df01bcd4217df9efd7da64fb48533a480228 Mon Sep 17 00:00:00 2001 From: Tiago Neves Date: Wed, 25 Nov 2026 12:25:36 +0000 Subject: [PATCH 2/2] fix(deploy): npm ci --include=dev in webhook-deploy.sh (BIT-33336) Node 24/npm 11 omits devDependencies (tsc) on plain npm ci. Together with the CT225 hotfix drift (context_data, resolve endpoints) preserved from hotfix/ct225-drift-recent-errors. --- deploy/lxc/webhook-deploy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/lxc/webhook-deploy.sh b/deploy/lxc/webhook-deploy.sh index e50f667..1e3937b 100755 --- a/deploy/lxc/webhook-deploy.sh +++ b/deploy/lxc/webhook-deploy.sh @@ -27,10 +27,10 @@ git checkout "${_DEPLOY_BRANCH}" git merge --ff-only "origin/${_DEPLOY_BRANCH}" echo "webhook-deploy: npm ci + build (ingest-api, admin-ui, collector-worker, api)" -(cd "${_ROOT}/ingest-api" && npm ci && npm run build) -(cd "${_ROOT}/admin-ui" && npm ci && npm run build) -(cd "${_ROOT}/collector-worker" && npm ci && npm run build) -(cd "${_ROOT}/api" && npm ci && npm run build) +(cd "${_ROOT}/ingest-api" && npm ci --include=dev && npm run build) +(cd "${_ROOT}/admin-ui" && npm ci --include=dev && npm run build) +(cd "${_ROOT}/collector-worker" && npm ci --include=dev && npm run build) +(cd "${_ROOT}/api" && npm ci --include=dev && npm run build) if getent passwd error-reporting >/dev/null 2>&1; then chown -R error-reporting:error-reporting "${_ROOT}"