You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hkc-8010 (via GitHub)" <gi...@apache.org> on 2026/07/03 07:35:47 UTC
[PR] Prevent malformed OpenSearch log entries from crashing task log fetch [airflow]
hkc-8010 opened a new pull request, #69307:
URL: https://github.com/apache/airflow/pull/69307
## Summary
- A single stored log entry with a non-string `event` field (for example, a task that
logs a list or dict as the sole message argument) currently crashes the entire
task-log-fetch request with an unhandled pydantic.ValidationError, instead of
degrading gracefully.
- `_read()` built `StructuredLogMessage` objects from stored OpenSearch hits without
catching validation failures. This change catches `ValidationError` per hit and falls
back to a stringified event, matching the existing fallback pattern in
`file_task_handler.py`'s `_log_stream_to_parsed_log_stream`. The identical pattern was
independently fixed in the Elasticsearch provider in #69306.
## Changes
- `providers/opensearch/src/airflow/providers/opensearch/log/os_task_handler.py`:
wrap `StructuredLogMessage` construction in a try/except `ValidationError` with a
stringified-event fallback and a warning log.
- `providers/opensearch/tests/unit/opensearch/log/test_os_task_handler.py`: add
coverage for malformed `event` handling and for `read()` surviving one bad hit among
otherwise-valid hits.
## PR Checklist
- [x] My PR is targeted at the `main` branch
- [x] Tests added/updated
- [x] `prek` hooks all pass
- [x] Unit tests pass locally
Related: #69304
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prevent malformed OpenSearch log entries from crashing task log fetch [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #69307:
URL: https://github.com/apache/airflow/pull/69307#issuecomment-4883261365
cc @Owen-CH-Leung
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prevent malformed OpenSearch log entries from crashing task log fetch [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #69307:
URL: https://github.com/apache/airflow/pull/69307
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prevent malformed OpenSearch log entries from crashing task log fetch [airflow]
Posted by "hkc-8010 (via GitHub)" <gi...@apache.org>.
hkc-8010 commented on PR #69307:
URL: https://github.com/apache/airflow/pull/69307#issuecomment-4958113152
@Vamsi-klu Good catch on the code path. I left the timestamp as-is on purpose here: in both handlers the timestamp is not user data. It is written by `OpensearchJSONFormatter.formatTime()` (Elasticsearch uses the same pattern) from `record.created`, so it is always a valid ISO-8601 string. The only field a user can put arbitrary values in is `event`, for example logging a list or dict, which is what the fallback and the test cover. A timestamp that fails validation would have to come from documents written into the index by something outside Airflow's own formatter. That is out of scope for this fix, so I would rather keep the fallback narrow. If we want to harden against externally ingested log docs, I am happy to do that as a follow-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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prevent malformed OpenSearch log entries from crashing task log fetch [airflow]
Posted by "Vamsi-klu (via GitHub)" <gi...@apache.org>.
Vamsi-klu commented on PR #69307:
URL: https://github.com/apache/airflow/pull/69307#issuecomment-4889070574
Could the fallback avoid reusing the original `timestamp` when validation failed? Right now any `ValidationError` falls into the except block, but then it builds `StructuredLogMessage(..., timestamp=fields.get("timestamp"))`. If the malformed field was `timestamp` rather than `event`, the fallback can raise the same validation error again and still fail the whole log fetch.
---
Drafted-by: Codex (GPT-5); reviewed by @Vamsi-klu before posting
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org