Compare commits

...

2 Commits

Author SHA1 Message Date
Henry
de6bb7572f feat: enhance logging with request input 2026-03-23 22:30:24 +00:00
Henry
c0aae5449f fix: prevent invalid calls to fetch label by publicId (#449)
* fix: prevent invalid calls to fetch label by publicId

* fix: ensure query only runs when isEdit is true
2026-03-23 21:40:35 +00:00
2 changed files with 4 additions and 3 deletions

View File

@@ -39,7 +39,7 @@ export function LabelForm({
labelPublicId: entityId, labelPublicId: entityId,
}, },
{ {
enabled: isEdit && !!entityId, enabled: !!isEdit && entityId.length >= 12,
}, },
); );

View File

@@ -163,9 +163,9 @@ export const createTRPCRouter = t.router;
export const createCallerFactory = t.createCallerFactory; export const createCallerFactory = t.createCallerFactory;
const loggingMiddleware = t.middleware(async ({ path, type, next, ctx }) => { const loggingMiddleware = t.middleware(async ({ path, type, next, ctx, getRawInput }) => {
const start = Date.now(); const start = Date.now();
const result = await next(); const [result, input] = await Promise.all([next(), getRawInput().catch(() => undefined)]);
const duration = Date.now() - start; const duration = Date.now() - start;
const { user, transport, requestId } = ctx as { const { user, transport, requestId } = ctx as {
@@ -182,6 +182,7 @@ const loggingMiddleware = t.middleware(async ({ path, type, next, ctx }) => {
duration, duration,
userId: user?.id, userId: user?.id,
...(isCloud && { email: user?.email }), ...(isCloud && { email: user?.email }),
input,
}; };
const label = transport === "rest" ? "REST" : "tRPC"; const label = transport === "rest" ? "REST" : "tRPC";