Skip to content

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

Open
Subham-KRLX wants to merge 1 commit intoapache:mainfrom
Subham-KRLX:fix-63736-es-error-detail-missing
Open

fix: Elasticsearch logging exception details are missing in task logs tab#63739
Subham-KRLX wants to merge 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 2 times, most recently from 5c00a18 to f349d75 Compare March 18, 2026 10:54
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't vouch for the provider change

@@ -0,0 +1 @@
Fix missing traceback in Elasticsearch and OpenSearch task logs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this file. We do not use bugfix newsfragment anymore.

@eladkal
Copy link
Contributor

eladkal commented Mar 20, 2026

cc @Owen-CH-Leung can you help with review?

@Owen-CH-Leung
Copy link
Contributor

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.

@eladkal eladkal changed the title Fix 63736 es error detail missing fix: Elasticsearch logging exception details are missing in task logs tab Mar 22, 2026
@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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I see the problem now.
What we need to do is to convert this file into a general example file like we have in
airflow-core/src/airflow/example_dags/example_skip_dag.py
kinda the same just for failure.
Then we can reference this example in elastic tests.

What confused me was that it was elastic example dag but we don't need elastic example any example of failure dag would fit (no need to mention elastic)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the example DAG back to Airflow Core (airflow-core/src/airflow/example_dags/example_failed_dag.py) and converted it into a generic failure example, removing any references to Elasticsearch. I also updated the Elasticsearch E2E test to reference this new general DAG ID.

@Subham-KRLX Subham-KRLX force-pushed the fix-63736-es-error-detail-missing branch from 335f12c to 69e329f Compare March 22, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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