Skip to content

Commit 1564778

Browse files
evan-onyxwenxi-onyx
authored andcommitted
fix: preserve error traces (#5083)
1 parent af0ac77 commit 1564778

File tree

1 file changed

+14
-9
lines changed
  • backend/onyx/background/celery/tasks/docfetching

1 file changed

+14
-9
lines changed

backend/onyx/background/celery/tasks/docfetching/tasks.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,20 @@ def docfetching_proxy_task(
552552
# print with exception
553553
try:
554554
with get_session_with_current_tenant() as db_session:
555-
failure_reason = (
556-
f"Spawned task exceptioned: exit_code={result.exit_code}"
557-
)
558-
mark_attempt_failed(
559-
ctx.index_attempt_id,
560-
db_session,
561-
failure_reason=failure_reason,
562-
full_exception_trace=result.exception_str,
563-
)
555+
attempt = get_index_attempt(db_session, ctx.index_attempt_id)
556+
557+
# only mark failures if not already terminal,
558+
# otherwise we're overwriting potential real stack traces
559+
if attempt and not attempt.status.is_terminal():
560+
failure_reason = (
561+
f"Spawned task exceptioned: exit_code={result.exit_code}"
562+
)
563+
mark_attempt_failed(
564+
ctx.index_attempt_id,
565+
db_session,
566+
failure_reason=failure_reason,
567+
full_exception_trace=result.exception_str,
568+
)
564569
except Exception:
565570
task_logger.exception(
566571
log_builder.build(

0 commit comments

Comments
 (0)