Repository navigation
fix(config): align additional_properties typing - #5286
hariharan077 wants to merge 4 commits into
Conversation
6b20701 to
8eb46b0
Compare
MikeGoldsmith
left a comment
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
|
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. |
934875a to
cf5c4f2
Compare
|
Rebased the PR onto current main and pushed cf5c4f2. This carries the additional_properties field change over the v1.1 schema update and keeps conversion/resource handling aligned with non-init dataclass fields. |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
Hi @hariharan077 - I'm sorry but this PR has been affected by another PR which moved a lot of the config into a new package. Please can you update your PR to use the new paths. |
cf5c4f2 to
859abf5
Compare
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
859abf5 to
f7592ff
Compare
Pull request dashboard statusWaiting on the author · refreshed 2026-10-22 17:41 UTC Investigate required status check failures. Status above doesn't look right?
|
This comment has been minimized.
This comment has been minimized.
Reapply the additional_properties dataclass-field change on top of the v1.1 declarative configuration schema update and keep conversion helpers from treating non-init fields as constructor kwargs. Assisted-by: GPT-5 Codex
f7592ff to
c695304
Compare
|
@MikeGoldsmith The path update requested after #5356 is included in c695304. The codegen template, generated models, conversion/resource handling, and tests now use the Could you please take another look? The CI, changelog, and check-links workflows currently report |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
@MikeGoldsmith The package-path changes requested after #5356 are included, along with the codegen README and changelog. Could you please take another look and let me know if anything else is needed? |
There was a problem hiding this comment.
🟡 Changes recommended
The generated root configuration annotation excludes schema-valid scalar and array extras, undermining the intended typing correction.
1 open issue
What changed in this PR
This PR addresses #5268 by aligning generated configuration model fields with the decorator’s runtime behavior and the component protocol.
Changes:
- Replaces
ClassVarannotations with non-init instance dataclass fields. - Skips non-init fields during dictionary conversion and resource detector resolution.
- Updates regression checks, code generation documentation, and the changelog.
| File | Description |
|---|---|
pyproject.toml |
Imports dataclasses.field for code generation. |
opentelemetry-configuration/tests/test_conversion.py |
Updates the conversion fixture to use an instance field. |
opentelemetry-configuration/tests/test_common.py |
Checks field metadata and instance isolation. |
opentelemetry-configuration/src/opentelemetry/configuration/models.py |
Regenerates additional-properties instance fields. |
opentelemetry-configuration/src/opentelemetry/configuration/_resource.py |
Excludes non-init fields from detector resolution. |
opentelemetry-configuration/src/opentelemetry/configuration/_conversion.py |
Excludes non-init fields from constructor-field conversion. |
opentelemetry-configuration/src/opentelemetry/configuration/_common.py |
Updates decorator field filtering and protocol documentation. |
opentelemetry-configuration/codegen/README.md |
Documents the instance-field design. |
opentelemetry-configuration/codegen/dataclass.jinja2 |
Generates typed non-init fields instead of class variables. |
.changelog/5286.fixed |
Records the configuration typing fix. |
Review effort: Balanced
Keep root configuration extras typed as Any while preserving object-or-null component extras. Regenerate models and cover annotations, constructor extras, and dictionary conversion. Assisted-by: Codex
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The additional-properties review item is fixed in 1064cc6, with regression coverage and 422 configuration tests plus 29 subtests passing locally. The inline thread is resolved. The new CI, changelog, check-links, and Zizmor runs report AI assistance: Codex implemented and locally validated this follow-up. |
|
Compatibility review for the current head I reproduced Griffe's However, making these real dataclass fields does change public behavior across all 13 models:
So the failure should not be dismissed as only a static-analysis false positive. The existing tests do not establish backwards compatibility for those behaviors. The package is documented as experimental, but whether to accept this change still needs a maintainer decision. @MikeGoldsmith, does the previously requested The earlier README, package-path, and changelog requests are present in the current diff. This compatibility decision is still open. AI assistance: Codex reproduced the checker and performed the model-level comparison; this is not human compatibility approval. |

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 and converting dictionaries to dataclasses, so the generated
additional_propertiesfield is not treated as a configured component name or constructor argument.Type of change
How Has This Been Tested?
SpanExporter/_resolve_componentrepro before the fixuv run tox -e generate-config-from-jsonschemauv run tox -r -e py310-test-opentelemetry-configuration(381 passed, 29 subtests passed)uv run tox -r -e lint-opentelemetry-configuration(Pylint10.00/10)uv run ruff check opentelemetry-configurationuv run ruff format --check opentelemetry-configurationuv run towncrier build --draft --version Unreleasedgit diff --checkDoes This PR Require a Contrib Repo Change?
Checklist:
Changelog and codegen README documentation are included for the
additional_propertiesfield design.Compatibility review — pending
At
558bf4b, the public-symbols check reports 13 generatedadditional_propertiesattribute-value changes. Reproduced with Griffe 1.15.0 against74544f0. Constructor signatures and runtime extras are unchanged, but the conversion from annotation-only ClassVars to dataclass fields changes equality, repr, and dataclass serialization/introspection. This should not be treated as confirmed non-breaking until maintainers decide whether those changes are intended. No compatibility exemption has been added.Detailed comparison and maintainer question.
AI assistance: Codex performed the compatibility comparison; human compatibility approval remains pending.