Re: [PR] Render stacktraces properly [airflow]

2025-04-05 Thread via GitHub


aritra24 commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2737463785

   for context this is the error at hand
   ```
   {
   "timestamp": "2025-03-19T15:00:52.088368Z",
   "event": "Task failed with exception",
   "level": "error",
   "logger": "task",
   "error_detail": [
   {
   "exc_type": "ZeroDivisionError",
   "exc_value": "division by zero",
   "exc_notes": [],
   "syntax_error": null,
   "is_cause": false,
   "frames": [
   {
   "filename": 
"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py",
   "lineno": 582,
   "name": "run"
   },
   {
   "filename": 
"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py",
   "lineno": 718,
   "name": "_execute_task"
   },
   {
   "filename": 
"/opt/airflow/task-sdk/src/airflow/sdk/definitions/baseoperator.py",
   "lineno": 373,
   "name": "wrapper"
   },
   {
   "filename": 
"/opt/airflow/airflow/decorators/base.py",
   "lineno": 252,
   "name": "execute"
   },
   {
   "filename": 
"/opt/airflow/task-sdk/src/airflow/sdk/definitions/baseoperator.py",
   "lineno": 373,
   "name": "wrapper"
   },
   {
   "filename": 
"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py",
   "lineno": 202,
   "name": "execute"
   },
   {
   "filename": 
"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py",
   "lineno": 226,
   "name": "execute_callable"
   },
   {
   "filename": 
"/opt/airflow/airflow/utils/operator_helpers.py",
   "lineno": 262,
   "name": "run"
   },
   {
   "filename": "/files/dags/sample_dag2.py",
   "lineno": 17,
   "name": "error"
   }
   ]
   }
   ]
   },
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-04-05 Thread via GitHub


aritra24 commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2005787185


##
airflow/ui/src/components/RenderStructuredLog.tsx:
##


Review Comment:
   Ack



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-26 Thread via GitHub


pierrejeambrun commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2754416157

   It's ok I just pushed it 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-26 Thread via GitHub


pierrejeambrun merged PR #47965:
URL: https://github.com/apache/airflow/pull/47965


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-26 Thread via GitHub


aritra24 commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2754420258

   Thanks! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-26 Thread via GitHub


aritra24 commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2754412870

   Huh, I was sure I deleted it... 🤔 perhaps some commit of mine brought it 
back. Let me remove it once more...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-26 Thread via GitHub


pierrejeambrun commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2754405362

   @aritra24  You marked 
https://github.com/apache/airflow/pull/47965#discussion_r2012133830 as resolved 
but I still see the statement. Did you push your latest change ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-25 Thread via GitHub


pierrejeambrun commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2012133830


##
airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const { error_detail: errorDetail, ...reStructured } = structured;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;

Review Comment:
   You don't need that anymore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-25 Thread via GitHub


pierrejeambrun commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2012133830


##
airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const { error_detail: errorDetail, ...reStructured } = structured;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;

Review Comment:
   You don't need that anymore since we use `reStructured` from now one.



##
airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined

Re: [PR] Render stacktraces properly [airflow]

2025-03-24 Thread via GitHub


aritra24 commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2011147036


##
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##
@@ -16,22 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { chakra, Code } from "@chakra-ui/react";
+import { chakra } from "@chakra-ui/react";
 import type { UseQueryOptions } from "@tanstack/react-query";
 import dayjs from "dayjs";
 import innerText from "react-innertext";
-import { Link } from "react-router-dom";
+import type { JSX } from "react/jsx-runtime";

Review Comment:
   Oops, I think it's auto adding it somehow. I removed it a couple times. It 
somehow sneaks back in if I don't pay attention to the auto imports.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-24 Thread via GitHub


jscheffl commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2010920612


##
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##
@@ -16,22 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { chakra, Code } from "@chakra-ui/react";
+import { chakra } from "@chakra-ui/react";
 import type { UseQueryOptions } from "@tanstack/react-query";
 import dayjs from "dayjs";
 import innerText from "react-innertext";
-import { Link } from "react-router-dom";
+import type { JSX } from "react/jsx-runtime";

Review Comment:
   Import really not needed. Can you remove? Then I think it is good to merge.
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-24 Thread via GitHub


aritra24 commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2748496037

   @pierrejeambrun / @bbovenzi all review comments should now be resolved. 
Could you take another look?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-24 Thread via GitHub


aritra24 commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2010063371


##
airflow-core/src/airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const errorDetail = "error_detail" in structured ? structured.error_detail : 
undefined;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;
+details = (errorDetail as Array).map((error) => {
+  const errorLines = error.frames.map((frame) => (
+
+  File{" "}
+  
+"{frame.filename}"

Review Comment:
   I think the linter had complained against it but I'll recheck.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-24 Thread via GitHub


aritra24 commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2010063853


##
airflow-core/src/airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const errorDetail = "error_detail" in structured ? structured.error_detail : 
undefined;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;

Review Comment:
   Ack, fair I'll update it. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-24 Thread via GitHub


pierrejeambrun commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2009973987


##
airflow-core/src/airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const errorDetail = "error_detail" in structured ? structured.error_detail : 
undefined;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;

Review Comment:
   Not fan of the delete, we could spread and use that:
   
   ```js
   const { errorDetail, ...structuredWithoutDetails} = profiles;
   ```
   
   `structuredWithoutDetails` is not a good name but it's just for the example.



##
airflow-core/src/airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,180 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: 

Re: [PR] Render stacktraces properly [airflow]

2025-03-21 Thread via GitHub


bbovenzi commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2744112694

   Mind updating the Logs.test.tsx? We should probably add a new test for this 
stacktrace change


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-21 Thread via GitHub


aritra24 commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2744118491

   Yup, trying to get my dev setup working again. Will get fixing once I manage 
to get that done 🥲


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


jscheffl commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2006465701


##
airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,177 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const errorDetail = "error_detail" in structured ? structured.error_detail : 
undefined;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;
+details = (errorDetail as Array).map((error) => {
+  const errorLines = error.frames.map((frame) => (
+
+  File{" "}
+  
+"{frame.filename}"
+  
+  , line {frame.lineno} in {frame.name}
+
+  ));
+
+  return (
+
+  
+
+  <>
+{" "}
+{error.exc_type}: {error.exc_value}
+  
+
+  
+  {errorLines}
+
+  );
+});
+  }
+
+  elements.push(
+
+  {event}:{details}
+,
+  );
+
+  for (const key in structured) {
+if (Object.hasOwn(structured, key)) {
+  elements.push(
+" ",
+
+  {key === "logger" ? "source" : key}={JSON.stringify(structured[key])}
+,
+  );
+}
+  }
+

Review Comment:
   Proposal alternative to render:
   ```suggestion
 return (
   
 
   
 {error.exc_type}: {error.exc_value}
   
 
 {errorLines}
   
 );
   });
 }
   
 elements.push(
   
 {event}:
   ,
 );
   
 for (const key in structured) {
   if (Object.hasOwn(structured, key)) {
 elements.push(
   " ",
   
 {key === "logger" ? "source" : 
key}={JSON.stringify(structured[key])}
   ,
 );
   }
 }
   
 elements.push(
   
 {details}
   ,
 );
   
   ```
   
   Then it would look like:
   
![image](https://github.com/user-attachments/assets/599da19d-6ae2-419a-b15b-273f69a46d4d)
   
   ...and folded:
   
![image](https://github.com/user-attachments/assets/2d6d2a76-95fd-4969-b8a1-88ab6ac1e2ce)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this servi

Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


aritra24 commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2005805606


##
airflow/ui/src/queries/useLogs.tsx:
##
@@ -16,22 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { chakra, Code } from "@chakra-ui/react";
+import { chakra } from "@chakra-ui/react";
 import type { UseQueryOptions } from "@tanstack/react-query";
 import dayjs from "dayjs";
 import innerText from "react-innertext";
-import { Link } from "react-router-dom";
+import type { JSX } from "react/jsx-runtime";

Review Comment:
   Ack



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


bbovenzi commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2005693880


##
airflow/ui/src/queries/useLogs.tsx:
##
@@ -16,22 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { chakra, Code } from "@chakra-ui/react";
+import { chakra } from "@chakra-ui/react";
 import type { UseQueryOptions } from "@tanstack/react-query";
 import dayjs from "dayjs";
 import innerText from "react-innertext";
-import { Link } from "react-router-dom";
+import type { JSX } from "react/jsx-runtime";

Review Comment:
   We don't need this import



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


bbovenzi commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2005676225


##
airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,177 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const errorDetail = "error_detail" in structured ? structured.error_detail : 
undefined;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;

Review Comment:
   Why are we deleting this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


bbovenzi commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2005686835


##
airflow/ui/src/components/RenderStructuredLog.tsx:
##


Review Comment:
   `renderStructuredLog` since it doesn't actually return a named component



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


bbovenzi commented on code in PR #47965:
URL: https://github.com/apache/airflow/pull/47965#discussion_r2005676225


##
airflow/ui/src/components/RenderStructuredLog.tsx:
##
@@ -0,0 +1,177 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { chakra, Code } from "@chakra-ui/react";
+import { Link } from "react-router-dom";
+
+import type { StructuredLogMessage } from "openapi/requests/types.gen";
+import Time from "src/components/Time";
+import { LogLevel, logLevelColorMapping } from "src/utils/logs";
+
+type Frame = {
+  filename: string;
+  lineno: number;
+  name: string;
+};
+
+type ErrorDetail = {
+  exc_notes: Array;
+  exc_type: string;
+  exc_value: string;
+  frames: Array;
+  is_cause: boolean;
+  syntax_error: string | null;
+};
+
+type RenderStructuredLogProps = {
+  index: number;
+  logLevelFilters?: Array;
+  logLink: string;
+  logMessage: string | StructuredLogMessage;
+  sourceFilters?: Array;
+};
+
+export const renderStructuredLog = ({
+  index,
+  logLevelFilters,
+  logLink,
+  logMessage,
+  sourceFilters,
+}: RenderStructuredLogProps) => {
+  if (typeof logMessage === "string") {
+return (
+  
+{logMessage}
+  
+);
+  }
+
+  const { event, level = undefined, timestamp, ...structured } = logMessage;
+
+  const elements = [];
+
+  if (
+logLevelFilters !== undefined &&
+Boolean(logLevelFilters.length) &&
+((typeof level === "string" && !logLevelFilters.includes(level)) || 
!Boolean(level))
+  ) {
+return "";
+  }
+
+  if (
+sourceFilters !== undefined &&
+Boolean(sourceFilters.length) &&
+(("logger" in structured && !sourceFilters.includes(structured.logger as 
string)) ||
+  !("logger" in structured))
+  ) {
+return "";
+  }
+
+  elements.push(
+
+  {index}
+,
+  );
+
+  if (Boolean(timestamp)) {
+elements.push("[", , "] ");
+  }
+
+  if (typeof level === "string") {
+elements.push(
+  
+{level.toUpperCase()}
+  ,
+  " - ",
+);
+  }
+
+  const errorDetail = "error_detail" in structured ? structured.error_detail : 
undefined;
+  let details;
+
+  if (errorDetail !== undefined) {
+delete structured.error_detail;

Review Comment:
   Why are we deleting this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


bbovenzi commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2740483097

   +1 on indentation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-20 Thread via GitHub


ashb commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2739955418

   Display looks nice, but the indentation of display needs a bit of work.
   
   Thanks for picking this up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Render stacktraces properly [airflow]

2025-03-19 Thread via GitHub


aritra24 commented on PR #47965:
URL: https://github.com/apache/airflow/pull/47965#issuecomment-2737460452

   https://github.com/user-attachments/assets/187fed9e-2aa9-4fd9-bdb3-01a211154a1a";
 />
   First pass at fixing the stacktraces in logs, still need to make it 
prettier. So any recommendations are welcome...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org