Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a55df01bc | ||
|
|
40c646ab4b | ||
|
|
3abd4ab804 | ||
|
|
7bc04e8e1b |
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 },
|
||||
});
|
||||
}
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in new issue
Block a user