Skip to content

Commit d181640

Browse files
committed
review changes
1 parent c55ab1e commit d181640

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

apps/webapp/app/presenters/v3/LogDetailPresenter.server.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,10 @@ export class LogDetailPresenter {
7070

7171
const log = records[0];
7272

73-
// Parse metadata and attributes
74-
let parsedMetadata: Record<string, unknown> = {};
73+
7574
let parsedAttributes: Record<string, unknown> = {};
7675
let rawAttributesString = "";
7776

78-
try {
79-
if (log.metadata) {
80-
parsedMetadata = JSON.parse(log.metadata) as Record<string, unknown>;
81-
}
82-
} catch {
83-
// Ignore parse errors
84-
}
8577

8678
try {
8779
// Handle attributes_text which is a string
@@ -107,10 +99,8 @@ export class LogDetailPresenter {
10799
status: log.status,
108100
duration: typeof log.duration === "number" ? log.duration : Number(log.duration),
109101
level: kindToLevel(log.kind, log.status),
110-
metadata: parsedMetadata,
111102
attributes: parsedAttributes,
112103
// Raw strings for display
113-
rawMetadata: log.metadata,
114104
rawAttributes: rawAttributesString,
115105
};
116106
}

apps/webapp/app/presenters/v3/LogsListPresenter.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ export class LogsListPresenter extends BasePresenter {
544544
// For error logs with status ERROR, try to extract error message from attributes
545545
if (log.status === "ERROR" && log.attributes_text) {
546546
try {
547-
let attributes = JSON.parse(log.attributes_text) as ErrorAttributes;
547+
const attributes = JSON.parse(log.attributes_text) as ErrorAttributes;
548548

549549
if (attributes?.error?.message && typeof attributes.error.message === "string") {
550550
displayMessage = attributes.error.message;

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,20 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
9898
const userId = user.id;
9999
const isAdmin = user.admin || user.isImpersonating;
100100

101-
if (!isAdmin) {
102-
throw redirect("/");
103-
}
104101

105102
const { projectParam, organizationSlug, envParam } = EnvironmentParamSchema.parse(params);
106103

104+
const canAccess = await hasLogsPageAccess(
105+
userId,
106+
user.admin,
107+
user.isImpersonating,
108+
organizationSlug
109+
);
110+
111+
if(!canAccess) {
112+
throw redirect("/");
113+
}
114+
107115
const project = await findProjectBySlug(organizationSlug, projectParam, userId);
108116
if (!project) {
109117
throw new Response("Project not found", { status: 404 });

0 commit comments

Comments
 (0)