Skip to content

fix: Elasticsearch logging exception details are missing in task logs tab#63739

Merged
eladkal merged 1 commit intoapache:mainfrom
Subham-KRLX:fix-63736-es-error-detail-missing
Mar 22, 2026
Merged

fix: Elasticsearch logging exception details are missing in task logs tab#63739
eladkal merged 1 commit intoapache:mainfrom
Subham-KRLX:fix-63736-es-error-detail-missing

Conversation

@Subham-KRLX
Copy link
Contributor

@Subham-KRLX Subham-KRLX commented Mar 16, 2026

Description

Fixes #63736: Restores missing stack traces in Airflow 3 logs for Elasticsearch and OpenSearch.

Changes:

  • Adds error_detail to TASK_LOG_FIELDS to ensure exception data is retrieved.
  • Implements _format_error_detail to render structured exception payloads into readable tracebacks for the UI.
  • Adds comprehensive unit tests for formatting logic and end-to-end flow in both providers.

closes: #63736


Was generative AI tooling used to co-author this PR?
  • Yes — Gemini(Research for changes ,Title and pr description )

@potiuk
Copy link
Member

potiuk commented Mar 17, 2026

@Subham-KRLX This PR has been converted to draft because it does not yet meet our Pull Request quality criteria.

Issues found:

  • Merge conflicts: This PR has merge conflicts with the main branch. Your branch is 14 commits behind main. Please rebase your branch (git fetch origin && git rebase origin/main), resolve the conflicts, and push again. See contributing quick start.

Note: Your branch is 14 commits behind main. Some check failures may be caused by changes in the base branch rather than by your PR. Please rebase your branch and push again to get up-to-date CI results.

What to do next:

  • The comment informs you what you need to do.
  • Fix each issue, then mark the PR as "Ready for review" in the GitHub UI - but only after making sure that all the issues are fixed.
  • There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates.
  • Maintainers will then proceed with a normal review.

Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack.

@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from 76706ac to 902b587 Compare March 17, 2026 03:30
@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from 243d9c0 to 0979414 Compare March 22, 2026 05:57
@Subham-KRLX
Copy link
Contributor Author

Subham-KRLX commented Mar 22, 2026

Thanks @Subham-KRLX.

Could you please rebase on the latest main again? There will also be a new CI test covering the E2E Elasticsearch remote logging flow. Please also add an integration test in providers/elasticsearch/tests/integration/elasticsearch/log/test_es_remote_log_io.py to verify reading exception/error details from Elasticsearch, and a corresponding test under TestElasticsearchRemoteLogIO.

I have rebased the branch on the latest main, added the requested integration test in providers/elasticsearch/tests/integration/elasticsearch/log/test_es_remote_log_io.py, and included a corresponding unit test under TestElasticsearchRemoteLogIO in test_es_task_handler.py.Verified locally that the new tests pass and error_detail is correctly formatted.

@Owen-CH-Leung
Copy link
Contributor

Screenshot from 2026-03-22 15-52-08

I run airflow on your branch and create a task that raise Exception. The task log is not rendered.

However, I can see the exception log lines are in the elasticsearch.

@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from f1f99f7 to 8ccc4a8 Compare March 22, 2026 08:32
@Subham-KRLX
Copy link
Contributor Author

@Owen-CH-Leung The rendering issue was due to missing level and timestamp
field mappings from Elasticsearch (which uses levelname and @timestamp). I've now fixed this in _build_log_fields
to ensure compatibility with the Airflow 3 UI schema.I have also included the unit and integration tests you requested. Please take another look at the latest push (8ccc4a8).

@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from 8ccc4a8 to 98fbf83 Compare March 22, 2026 08:36
@eladkal eladkal added provider:opensearch and removed area:dev-tools area:UI Related to UI/UX. For Frontend Developers. provider:opensearch backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch labels Mar 22, 2026
@Owen-CH-Leung
Copy link
Contributor

Looks good now. Thanks!

Screenshot from 2026-03-22 17-06-03

One last request: can you also make changes on airflow-e2e-tests/tests/airflow_e2e_tests/remote_log_elasticsearch_tests/test_remote_logging_elasticsearch.py to include a test to retrieve stackTrace ?

Thanks a lot for your work!

@eladkal
Copy link
Contributor

eladkal commented Mar 22, 2026

Note also the integration test fails
FAILED providers/elasticsearch/tests/integration/elasticsearch/log/test_es_remote_log_io.py::TestElasticsearchRemoteLogIOIntegration::test_upload_and_read - AssertionError: assert 'message' in {'event': 'start'}

@eladkal
Copy link
Contributor

eladkal commented Mar 22, 2026

I think there is some kind of broken rebase or you attempt to fix issues in main branch as part of this PR?
There should be no changes to amazon and the other providers as part of this PR

@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from 4cf65a5 to 335f12c Compare March 22, 2026 10:26
@Subham-KRLX
Copy link
Contributor Author

I performed a clean rebase onto main to remove all unrelated file changes, so the branch now only contains the 7 relevant files for this fix. I also relocated the new example DAG to the provider-specific path (providers/elasticsearch/src/airflow/providers/elasticsearch/example_dags/). Finally I updated the integration test assertions to expect the event field and included the new E2E test for stack trace retrieval in the Elasticsearch remote logging suite.

@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from 335f12c to 69e329f Compare March 22, 2026 11:50
@eladkal eladkal added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Mar 22, 2026
@eladkal eladkal added this to the Airflow 3.2.0 milestone Mar 22, 2026
@eladkal
Copy link
Contributor

eladkal commented Mar 22, 2026

Merging.
No need to backport, I set skip change log label so it won't be reflected in 3.2 change log (the core part is just the system test)

@eladkal eladkal merged commit 96eefca into apache:main Mar 22, 2026
147 checks passed
Kundan-CR7 pushed a commit to Kundan-CR7/airflow that referenced this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:logging area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) provider:elasticsearch provider:opensearch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception details are missing in Airflow task logs tab when using Elasticsearch to store logs

5 participants