Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ describe("Task log grouping", () => {

fireEvent.click(collapseItem);

expect(screen.getByText(/Marking task as SUCCESS/iu)).toBeVisible();
await waitFor(() => expect(screen.queryByText(/Marking task as SUCCESS/iu)).toBeVisible());
}, 10_000);
});
5 changes: 3 additions & 2 deletions airflow-core/src/airflow/ui/src/queries/useLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type { TaskInstanceResponse, TaskInstancesLogResponse } from "openapi/req
import { renderStructuredLog } from "src/components/renderStructuredLog";
import { isStatePending, useAutoRefresh } from "src/utils";
import { getTaskInstanceLink } from "src/utils/links";
import { parseStreamingLogContent } from "src/utils/logs";

type Props = {
accept?: "*/*" | "application/json" | "application/x-ndjson";
Expand Down Expand Up @@ -180,7 +181,7 @@ const parseLogs = ({

export const useLogs = (
{
accept = "application/json",
accept = "application/x-ndjson",
dagId,
expanded,
logLevelFilters,
Expand Down Expand Up @@ -217,7 +218,7 @@ export const useLogs = (
);

const parsedData = parseLogs({
data: data?.content ?? [],
data: parseStreamingLogContent(data),
expanded,
logLevelFilters,
showSource,
Expand Down
21 changes: 21 additions & 0 deletions airflow-core/src/airflow/ui/src/utils/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/* eslint-disable perfectionist/sort-objects */
import { createListCollection } from "@chakra-ui/react";

import type { TaskInstancesLogResponse } from "openapi/requests/types.gen";

export enum LogLevel {
DEBUG = "debug",
INFO = "info",
Expand Down Expand Up @@ -51,3 +53,22 @@ export const logLevelOptions = createListCollection<{
{ label: "dag:logs.critical", value: LogLevel.CRITICAL },
],
});

export const parseStreamingLogContent = (
data: TaskInstancesLogResponse | undefined,
): TaskInstancesLogResponse["content"] => {
if (!data?.content) {
const content = data as unknown as string;

try {
return content
.split("\n")
.filter((line) => line.trim() !== "")
.map((line) => JSON.parse(line) as string);
} catch {
return [];
}
}

return data.content;
};
Loading