Merge pull request 'fix(hub): preserve CT225 drift (context_data, resolve endpoints) + npm ci --include=dev (BIT-33336)' (#21) from task/BIT-33336-hotfix-drift-npm-ci into master
CI / Test ingest-api (push) Successful in 22s
CI / Test api (push) Successful in 23s
CI / Lint and typecheck admin-ui (push) Successful in 56s
CI / Validate Docker build (push) Successful in 3m26s

This commit was merged in pull request #21.
This commit is contained in:
tiago-neves committed 2026-11-25 12:29:28 +00:00
commit 4bd1983645
4 files changed
+123 -4

No files matched your search

@@ -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<string, string> = {
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 },
});
}
@@ -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<string, string> = {
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 },
});
}
+25
View File
@@ -109,6 +109,29 @@ function parseStatusList(raw: string | undefined): string[] | null {
return parts.length > 0 ? parts : ['open', 'investigating'];
}
function slimContext(ctx: Record<string, unknown> | null): Record<string, unknown> | null {
if (!ctx) return null;
const out: Record<string, unknown> = {};
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<string, unknown> = {};
for (const [key, item] of Object.entries(value as Record<string, unknown>).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<void> {
const db = request.server.db;
@@ -321,6 +344,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;
});
+4 -4
View File
@@ -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}"