Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/5436.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry-configuration`: resolve false-positive warning logs for newer schema minor version
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Which fields of the configuration schema the Python SDK actually applies at runt
tox -e generate-config-from-jsonschema
```

3. Update any version string references in tests and source:
3. Bump `_SUPPORTED_SCHEMA_MAJOR` / `_SUPPORTED_SCHEMA_MINOR` in `file/_loader.py` to the version of the vendored schema.

4. Update any version string references in tests and source:

```sh
grep -r "OLD_VERSION" opentelemetry-configuration/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# warning. See
# https://github.com/open-telemetry/opentelemetry-configuration/blob/main/VERSIONING.md
_SUPPORTED_SCHEMA_MAJOR = 1
_SUPPORTED_SCHEMA_MINOR = 0
_SUPPORTED_SCHEMA_MINOR = 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the warning may be annoying the packages are shipping a 1.0 schema so if we bump here we are breaking support for them?

@herin049 herin049 Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_validate_file_format() doesn't log anything if the current minor is smaller than the latest supported. From my understanding, older minor versions should be fully supported, it's just newer supported minor versions that may include functionality which isn't implemented in the SDK (which is why we log). It's the same as SemVer semantics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ofc, all bets are off when using developmental features.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. just tested. didn't break for me while still using 1.0

@xrmx xrmx Jul 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I was confused by the reading the newer major test. Should we test the older minor as well if _SUPPORTED_SCHEMA_MINOR > 0?


_schema_cache: list[dict] = []

Expand Down
30 changes: 22 additions & 8 deletions opentelemetry-configuration/tests/file/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
ConfigurationError,
load_config_file,
)
from opentelemetry.configuration.file._loader import (
_SUPPORTED_SCHEMA_MAJOR,
_SUPPORTED_SCHEMA_MINOR,
)
from opentelemetry.configuration.models import (
BatchSpanProcessor as BatchSpanProcessorConfig,
)
Expand Down Expand Up @@ -331,6 +335,8 @@ def test_typed_config_feeds_factory_function(self):
class TestFileFormatValidation(unittest.TestCase):
"""Validate the file_format version per the configuration spec."""

_SUPPORTED = f"{_SUPPORTED_SCHEMA_MAJOR}.{_SUPPORTED_SCHEMA_MINOR}"

@staticmethod
def _load(file_format: str) -> OpenTelemetryConfiguration:
with tempfile.NamedTemporaryFile(
Expand All @@ -344,26 +350,34 @@ def _load(file_format: str) -> OpenTelemetryConfiguration:
os.unlink(path)

def test_supported_version_is_accepted(self):
config = self._load("1.0")
self.assertEqual(config.file_format, "1.0")
with self.assertNoLogs(
"opentelemetry.configuration.file._loader", level="WARNING"
):
config = self._load(self._SUPPORTED)
self.assertEqual(config.file_format, self._SUPPORTED)

def test_pre_release_meta_tag_is_accepted(self):
# The meta tag is stripped; "1.0-rc.2" is treated as 1.0.
config = self._load("1.0-rc.2")
self.assertEqual(config.file_format, "1.0-rc.2")
# The meta tag is stripped, so the version is read as the supported one.
version = f"{self._SUPPORTED}-rc.2"
config = self._load(version)
self.assertEqual(config.file_format, version)

def test_newer_minor_is_accepted_with_warning(self):
version = f"{_SUPPORTED_SCHEMA_MAJOR}.{_SUPPORTED_SCHEMA_MINOR + 1}"
with self.assertLogs(
"opentelemetry.configuration.file._loader", level="WARNING"
) as logs:
config = self._load("1.1")
self.assertEqual(config.file_format, "1.1")
config = self._load(version)
self.assertEqual(config.file_format, version)
self.assertTrue(
any("newer minor version" in message for message in logs.output)
)

def test_unsupported_major_is_rejected(self):
for version in ("2.0", "0.4"):
versions = [f"{_SUPPORTED_SCHEMA_MAJOR + 1}.0"]
if _SUPPORTED_SCHEMA_MAJOR > 0:
versions.append(f"{_SUPPORTED_SCHEMA_MAJOR - 1}.0")
Comment on lines +378 to +379

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can just hardcode 0.4 since we aren't going backwards from 1.0?

for version in versions:
with self.subTest(version=version):
with self.assertRaises(ConfigurationError) as ctx:
self._load(version)
Expand Down
Loading