Repository navigation
Stringify task_instance.id when setting OTEL span attribute - #66053
Merged
Merged
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
2 tasks done
henry3260
reviewed
Apr 29, 2026
henry3260
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your effort !
The execution API's _emit_task_span() was setting the
"airflow.task_instance.id" span attribute to the raw UUID object.
The OTEL SDK only accepts str/bytes/int/float/bool attribute values
(or homogeneous sequences thereof), so it dropped the attribute and
logged a warning per task state transition:
Invalid type UUID for attribute 'airflow.task_instance.id'
value. Expected one of ['bool', 'str', 'bytes', 'int', 'float']
or a sequence of those types
The fix is to stringify the UUID, matching the convention already
used in the same module (e.g. bind_contextvars(ti_id=str(...))).
The bug was introduced in apache#63839 and ships in 3.2.0 / 3.2.1.
Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com>
Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com>
Reviewer (henry3260) noted the newsfragment isn't needed for this fix.
c-premus
force-pushed
the
fix/otel-ti-id-uuid-attr
branch
from
April 29, 2026 11:06
050d18f to
3b980b9
Compare
potiuk
approved these changes
May 10, 2026
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Contributor
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
potiuk
pushed a commit
that referenced
this pull request
May 10, 2026
…te (#66053) (#66645) * Stringify task_instance.id when setting OTEL span attribute The execution API's _emit_task_span() was setting the "airflow.task_instance.id" span attribute to the raw UUID object. The OTEL SDK only accepts str/bytes/int/float/bool attribute values (or homogeneous sequences thereof), so it dropped the attribute and logged a warning per task state transition: Invalid type UUID for attribute 'airflow.task_instance.id' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types The fix is to stringify the UUID, matching the convention already used in the same module (e.g. bind_contextvars(ti_id=str(...))). The bug was introduced in #63839 and ships in 3.2.0 / 3.2.1. * Add newsfragment for OTEL UUID attribute fix * Drop newsfragment per review feedback Reviewer (henry3260) noted the newsfragment isn't needed for this fix. --------- (cherry picked from commit 8310049) Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com> Co-authored-by: Chris Premus <63758245+c-premus@users.noreply.github.com>
jason810496
pushed a commit
to jason810496/airflow
that referenced
this pull request
May 11, 2026
…6053) * Stringify task_instance.id when setting OTEL span attribute The execution API's _emit_task_span() was setting the "airflow.task_instance.id" span attribute to the raw UUID object. The OTEL SDK only accepts str/bytes/int/float/bool attribute values (or homogeneous sequences thereof), so it dropped the attribute and logged a warning per task state transition: Invalid type UUID for attribute 'airflow.task_instance.id' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types The fix is to stringify the UUID, matching the convention already used in the same module (e.g. bind_contextvars(ti_id=str(...))). The bug was introduced in apache#63839 and ships in 3.2.0 / 3.2.1. Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com> * Add newsfragment for OTEL UUID attribute fix Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com> * Drop newsfragment per review feedback Reviewer (henry3260) noted the newsfragment isn't needed for this fix. --------- Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
May 20, 2026
…te (#66053) (#66645) * Stringify task_instance.id when setting OTEL span attribute The execution API's _emit_task_span() was setting the "airflow.task_instance.id" span attribute to the raw UUID object. The OTEL SDK only accepts str/bytes/int/float/bool attribute values (or homogeneous sequences thereof), so it dropped the attribute and logged a warning per task state transition: Invalid type UUID for attribute 'airflow.task_instance.id' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types The fix is to stringify the UUID, matching the convention already used in the same module (e.g. bind_contextvars(ti_id=str(...))). The bug was introduced in #63839 and ships in 3.2.0 / 3.2.1. * Add newsfragment for OTEL UUID attribute fix * Drop newsfragment per review feedback Reviewer (henry3260) noted the newsfragment isn't needed for this fix. --------- (cherry picked from commit 8310049) Signed-off-by: Chris <63758245+c-premus@users.noreply.github.com> Co-authored-by: Chris Premus <63758245+c-premus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #66052
Summary
_emit_task_span()in the execution API was setting theairflow.task_instance.idspan attribute to the rawUUIDobject. The OTEL SDK only acceptsstr / bytes / int / float / boolattribute values (or homogeneous sequences), so it dropped the attribute and logged a warning per task state transition:The fix stringifies the UUID, matching the convention already used at the top of the same module (
bind_contextvars(ti_id=str(task_instance_id))).Root cause
Introduced in #63839 (merged 2026-03-24, "Introduce parent task spans and nest worker and trigger spans under them"). First shipped in 3.2.0; reproducible on 3.2.1 and
main.Reproduction
[traces] otel_on = Trueand an OTLP endpoint).docker logs <api-server> | grep "Invalid type UUID"— one warning per task state transition.Impact
Cosmetic but noisy — the task itself runs fine, the span is still emitted with the other attributes (
dag_id,task_id,run_id,try_number,map_index,state), only the TI UUID attribute is dropped. This prevents trace search by task instance ID in the trace backend.Tests
Extended
TestEmitTaskSpan.test_emit_task_span_sets_attributesto set a real UUID on the mock TI and assert the span attribute is present, equal tostr(ti.id), and of typestr.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Anthropic) following the guidelines