Skip to content

fix(api): prevent recursive attribute value crashes - #1

Closed
codedbyadiiii wants to merge 12 commits into
mainfrom
fix-issue-5564
Closed

codedbyadiiii wants to merge 12 commits into
mainfrom
fix-issue-5564

Conversation

@codedbyadiiii

Copy link
Copy Markdown
Owner

Description

Attribute values containing self-referential or excessively nested sequences and mappings could raise RecursionError during attribute cleaning.

This change limits recursive attribute processing to 20 levels. Values exceeding the limit are replaced with None and a warning is logged, while valid sibling attributes are preserved.

The fix also applies to metric attributes and adds regression tests for API attributes, spans, and resources.

Fixes open-telemetry#5564

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change

How Has This Been Tested?

  • API attribute tests
  • SDK span and resource tests
  • Ruff check and formatting
  • Full attribute regression coverage for cyclic and deeply nested values

emdneto and others added 12 commits October 5, 2026 15:08
…en-telemetry#5744)

Refactor pull request creation to capture URL output and add backport label.
…lemetry#5746)

* opentelemetry-api: improve performance of tracestate parsing

* add changelog fragment

* update optional whitespace comment
…ic (open-telemetry#5706)

* opentelemetry-sdk: fix thread leak bug in resource initialization logic

* add changelog fragment
…telemetry#5742)

SynchronousMultiLogRecordProcessor.__init__,
ConcurrentMultiLogRecordProcessor.__init__, and
ConcurrentMultiLogRecordProcessor.add_log_record_processor were missing
return type annotations. The Concurrent add_log_record_processor already
had the annotation on its Synchronous sibling, so the pair was
inconsistent. SynchronousMultiLogRecordProcessor.__init__ has no
annotated parameters either, so mypy --strict reports no-untyped-call
for downstream callers constructing it in typed contexts.

This follows open-telemetry#5709 and open-telemetry#5718, which annotated InMemoryLogRecordExporter
and ConsoleLogRecordExporter in the same package.

Assisted-by: Hermes Agent (stealth/space-bunny-alpha)

Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
* ci: add shared zizmor workflow

* ci: remediate zizmor findings in Python workflows

Pin and scope workflow dependencies, pass PR metadata through environments, and document the remaining publishing exceptions.

Assisted-by: GitHub Copilot

* ci: keep contrib integration workflow on main

Assisted-by: GPT-6.1 Sol
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Emídio <9735060+emdneto@users.noreply.github.com>
…elemetry#5402)

* opentelemetry-codegen-json: support decoding enums from names

* add changelog fragment

* update 'decode_enum' error messages

* fix formatting

* fix version

* update 'decode_enum' type annotation

* switch from raising KeyError to ValueError
…bled (open-telemetry#5741)

* opentelemetry-sdk: omit histogram min/max when record_min_max is disabled

* add changelog fragment

* add additional test cases
* docs: clarify baggage current context behavior

* docs: remove baggage reference from context docs

---------

Co-authored-by: Leighton Chen <lechen@microsoft.com>
…lifecycle (open-telemetry#5738)

* opentelemetry-test-utils: support Weaver 0.27 and improve live-check lifecycle

Assisted-by: ChatGPT

* Name changelog fragment for PR 5738

* Reject non-finite Weaver startup timeouts and fix test lint

Assisted-by: ChatGPT
…vars (open-telemetry#5448)

* Fall back to the default when an OTLP gRPC timeout env var is invalid

The gRPC exporters parse their timeout environment variables with a bare
float(), so a value like OTEL_EXPORTER_OTLP_TIMEOUT=10s raises ValueError
during exporter construction and takes down SDK startup.

Add a shared _timeout_from_env() helper in opentelemetry-exporter-otlp-
proto-common that warns and falls back instead, matching how the repo
already handles invalid temporality and export-interval values, and use it
from the gRPC mixin and the three signal exporters. Precedence between the
signal-specific and generic variables is unchanged.

Also fix `timeout or ...` silently discarding an explicit timeout=0; it is
now `timeout is not None`.

The HTTP exporters got the same treatment in open-telemetry#5389, so this change is
limited to the gRPC exporters.

* Move _timeout_from_env into the gRPC exporter package

Only the gRPC exporters use it now that the HTTP side landed in open-telemetry#5389.

It lives in the package __init__ rather than exporter.py because the
logger there has a DuplicateFilter keyed on the message template, which
would drop the warning for a second invalid variable.

* Leave the timeout=0 handling unchanged

Honouring an explicit timeout=0 makes the gRPC exporter set a deadline
that has already passed, so every export fails with DEADLINE_EXCEEDED.
Declarative config passes timeout=0 for "no limit", so that needs its own
change. Keep the existing `timeout or ...` fallback here.

---------

Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self-referential attribute value crashes the instrumented application with RecursionError

8 participants