This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 081637e083 Provide a UUID to trace log when RPC internal server
error... WDYT? (#38989)
081637e083 is described below
commit 081637e083da02e5500550db682a869f25324096
Author: Daniel Standish <[email protected]>
AuthorDate: Mon Apr 15 02:07:54 2024 -0700
Provide a UUID to trace log when RPC internal server error... WDYT? (#38989)
* Provide a UUID to trace log when RPC internal server error
For security reasons, we don't present the user with tracebacks when
there's a webserver error. If we similarly don't want to provide tracebacks in
task execution logs, we could provide a UUID that an admin can use to find the
error in the server logs.
(cherry picked from commit 5b6ef96989ff53f77713d00be85637d932d7d928)
* improve language of error message
---
airflow/api_internal/endpoints/rpc_api_endpoint.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/airflow/api_internal/endpoints/rpc_api_endpoint.py
b/airflow/api_internal/endpoints/rpc_api_endpoint.py
index b5fd545066..f2fa53d3ee 100644
--- a/airflow/api_internal/endpoints/rpc_api_endpoint.py
+++ b/airflow/api_internal/endpoints/rpc_api_endpoint.py
@@ -21,6 +21,7 @@ import functools
import json
import logging
from typing import TYPE_CHECKING, Any, Callable
+from uuid import uuid4
from flask import Response
@@ -139,7 +140,11 @@ def internal_airflow_api(body: dict[str, Any]) ->
APIResponse:
output_json = BaseSerialization.serialize(output,
use_pydantic_models=True)
response = json.dumps(output_json) if output_json is not None else
None
return Response(response=response, headers={"Content-Type":
"application/json"})
- except Exception as e:
- log.error("Error executing method: %s.", method_name)
- log.exception(e)
- return Response(response=f"Error executing method: {method_name}.",
status=500)
+ except Exception:
+ error_id = uuid4()
+ log.exception("Error executing method '%s'; error_id=%s.",
method_name, error_id)
+ return Response(
+ response=f"Error executing method '{method_name}'. "
+ f"The server side traceback may be identified with
error_id={error_id}",
+ status=500,
+ )