Skip to content

Commit 82c1292

Browse files
1stvampTrigger.dev RepoOps
authored andcommitted
chore(webapp): name the tenant in failure logs
Name the tenant on failure. Across 72 api, dashboard and resource routes, the catch-path log that reports a failure now includes the project, organization, environment or user the request was for, taken from the route params or the authenticated context already in scope. When one of these routes errors, the log line says whose request it was, which is what you need to trace an incident to a customer rather than reading it as an anonymous 500. Mono-RevId: 401cdce0cf3af4d56827815b11b0cf66ab6cd94f
1 parent b4057df commit 82c1292

72 files changed

Lines changed: 279 additions & 86 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.branches/route.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ export const loader = dashboardLoader(
127127
ability.can("write", { type: "deployments", envType: "PREVIEW" }),
128128
});
129129
} catch (error) {
130-
logger.error("Error loading preview branches page", { error });
130+
logger.error("Error loading preview branches page", {
131+
error,
132+
organizationSlug: params.organizationSlug,
133+
});
131134
throw new Response(undefined, {
132135
status: 400,
133136
statusText: "Something went wrong, if this problem persists please contact support.",

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.dev-branches/route.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ export const loader = dashboardLoader(
8181
ability.can("write", { type: "deployments", envType: "DEVELOPMENT" }),
8282
});
8383
} catch (error) {
84-
logger.error("Error loading dev branches page", { error });
84+
logger.error("Error loading dev branches page", {
85+
error,
86+
organizationSlug: params.organizationSlug,
87+
});
8588
throw new Response(undefined, {
8689
status: 400,
8790
statusText: "Something went wrong, if this problem persists please contact support.",

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues/route.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
253253
};
254254
}
255255
} catch (error) {
256-
logger.warn("Queue list metrics unavailable, rendering without them", { error });
256+
logger.warn("Queue list metrics unavailable, rendering without them", {
257+
error,
258+
organizationSlug: params.organizationSlug,
259+
});
257260
}
258261
}
259262

@@ -264,7 +267,10 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
264267
try {
265268
allocation = await new QueueAllocationPresenter().call({ environment });
266269
} catch (error) {
267-
logger.warn("Queue allocation summary unavailable, rendering without it", { error });
270+
logger.warn("Queue allocation summary unavailable, rendering without it", {
271+
error,
272+
organizationSlug: params.organizationSlug,
273+
});
268274
}
269275
}
270276

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ async function getRunsListFromTableState({
259259

260260
return runsList;
261261
} catch (error) {
262-
logger.error("Error loading runs list from tableState:", { error });
262+
logger.error("Error loading runs list from tableState:", { error, organizationSlug });
263263
return null;
264264
}
265265
}

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/route.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
153153
taskParam,
154154
error: error instanceof Error ? error.message : error,
155155
stack: error instanceof Error ? error.stack : undefined,
156+
organizationSlug,
156157
});
157158

158159
return redirectWithErrorMessage(
@@ -202,7 +203,10 @@ export const action: ActionFunction = async ({ request, params }) => {
202203
formAction,
203204
});
204205
} catch (e) {
205-
logger.error("Failed to create template", { error: e instanceof Error ? e.message : e });
206+
logger.error("Failed to create template", {
207+
error: e instanceof Error ? e.message : e,
208+
organizationSlug,
209+
});
206210
return redirectBackWithErrorMessage(request, "Failed to create template");
207211
}
208212
}
@@ -226,7 +230,10 @@ export const action: ActionFunction = async ({ request, params }) => {
226230
formAction,
227231
});
228232
} catch (e) {
229-
logger.error("Failed to delete template", { error: e instanceof Error ? e.message : e });
233+
logger.error("Failed to delete template", {
234+
error: e instanceof Error ? e.message : e,
235+
organizationSlug,
236+
});
230237
return redirectBackWithErrorMessage(request, "Failed to delete template");
231238
}
232239
}
@@ -275,7 +282,10 @@ export const action: ActionFunction = async ({ request, params }) => {
275282
);
276283
}
277284

278-
logger.error("Failed to start a test run", { error: e instanceof Error ? e.message : e });
285+
logger.error("Failed to start a test run", {
286+
error: e instanceof Error ? e.message : e,
287+
organizationSlug,
288+
});
279289

280290
return redirectBackWithErrorMessage(
281291
request,

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam/route.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
136136
]);
137137
} catch (error) {
138138
// The dashboard must load even when the agent's store doesn't answer.
139-
logger.error("Failed to read dashboard agent wake activity", { error });
139+
logger.error("Failed to read dashboard agent wake activity", { error, organizationSlug });
140140
}
141141
}
142142

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.settings._index/route.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ export const action = dashboardAction(
245245
const errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
246246
logger.error("Organization could not be deleted", {
247247
error: errorMessage,
248+
organizationSlug,
248249
});
249250
return redirectWithErrorMessage(
250251
organizationSettingsPath({ slug: organizationSlug }),

‎apps/webapp/app/routes/account.authorization-code.$authorizationCode/route.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
8181
return typedjson({ success: false as const, error: error.message, source, clientName });
8282
}
8383

84-
logger.error(JSON.stringify(error));
84+
logger.error(JSON.stringify(error), { userId });
8585
throw new Response(undefined, {
8686
status: 400,
8787
statusText: "Something went wrong, if this problem persists please contact support.",

‎apps/webapp/app/routes/api.v1.batches.$batchParam.results.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
4747
if (unroutable) {
4848
logger.warn("Unroutable batch id on batch results", {
4949
error: error instanceof Error ? error.message : error,
50+
environmentId: authenticationResult.environment.id,
5051
});
5152
return unroutable;
5253
}
5354

54-
logger.error("Failed to load batch results", { error });
55+
logger.error("Failed to load batch results", {
56+
error,
57+
environmentId: authenticationResult.environment.id,
58+
});
5559
return json({ error: "Something went wrong, please try again." }, { status: 500 });
5660
}
5761
} catch (error) {

‎apps/webapp/app/routes/api.v1.bulk-actions.$bulkActionId.abort.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ const { action } = createActionApiRoute(
3939
return json({ error: error.message }, { status: error.status ?? 400 });
4040
}
4141

42-
logger.error("Failed to abort API bulk action", { error });
42+
logger.error("Failed to abort API bulk action", {
43+
error,
44+
environmentId: authentication.environment.id,
45+
});
4346
return json({ error: "Failed to abort bulk action" }, { status: 500 });
4447
}
4548
}

0 commit comments

Comments
 (0)