fix(config): align additional_properties typing#5286
Open
hariharan077 wants to merge 3 commits into
Open
Conversation
Declare generated additional_properties fields as instance dataclass fields, matching the @_additional_properties decorator runtime behavior and _ComponentConfig protocol. Skip non-init dataclass fields when resolving configured resource detectors so the new generated field is not treated as a detector. Assisted-by: ChatGPT
6b20701 to
8eb46b0
Compare
MikeGoldsmith
requested changes
Jun 24, 2026
MikeGoldsmith
left a comment
Member
There was a problem hiding this comment.
Thanks @hariharan077 - sorry for the slow review.
There's a couple of things that need fixing:
- We're still importing
typing.ClassVar- I think we should be usingdataclasses.fieldinstead - The README.md needs updating with the new design, the field is now an init=False dataclass field with default_factory=dict and the @_additional_properties decorator assigns the extras in the constructor
- You need to add a changelog fragment, something like
.changelog/5286.fixed
Document that generated config models use an init=False dataclass field for additional_properties and add the changelog fragment requested in review. Assisted-by: GPT-5 Codex
Author
|
Addressed the review comments in ebb349e: updated the codegen README for the init=False/default_factory additional_properties field, added .changelog/5286.fixed, and refreshed the PR checklist. Local focused tests, SDK lint, ruff, and towncrier draft all pass. |
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.
Description
Fixes #5268.
Declare generated config model
additional_propertiesattributes as instance dataclass fields instead ofClassVars, matching the runtime behavior of@_additional_propertiesand the_ComponentConfigprotocol.This also skips non-init dataclass fields while resolving configured resource detectors, so the generated
additional_propertiesfield is not treated as a detector name.Type of change
How Has This Been Tested?
SpanExporter/_resolve_componentrepro before the fix0 errors, 0 warnings, 0 informations.tox/py310-test-opentelemetry-sdk/bin/python -m pytest opentelemetry-sdk/tests/_configuration/test_common.py opentelemetry-sdk/tests/_configuration/test_resource.py -quv run tox -r -e typecheckuv run tox -r -e lint-opentelemetry-sdkuv run ruff check opentelemetry-sdk/src/opentelemetry/sdk/_configuration/models.py opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_common.py opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_resource.py opentelemetry-sdk/tests/_configuration/test_common.pyuv run ruff format --check opentelemetry-sdk/src/opentelemetry/sdk/_configuration/models.py opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_common.py opentelemetry-sdk/src/opentelemetry/sdk/_configuration/_resource.py opentelemetry-sdk/tests/_configuration/test_common.pygit diff --checkDoes This PR Require a Contrib Repo Change?
Checklist:
Changelog and codegen README documentation are included for the
additional_propertiesfield design.