Skip to content

Fix/declarative config no exceptions#8079

Open
Bhagirath00 wants to merge 4 commits intoopen-telemetry:mainfrom
Bhagirath00:fix/declarative-config-no-exceptions
Open

Fix/declarative config no exceptions#8079
Bhagirath00 wants to merge 4 commits intoopen-telemetry:mainfrom
Bhagirath00:fix/declarative-config-no-exceptions

Conversation

@Bhagirath00
Copy link

issue: #7929

Description:

This PR updates the DeclarativeConfigProperties API to return null instead of throwing a DeclarativeConfigException when a property exists but has a different data type than requested (e.g., calling getBoolean on a String value).

Changes:

In DeclarativeConfigProperties.java (API): Updated Javadocs for all getter methods to explicitly state that they return null on type mismatch.
In YamlDeclarativeConfigPropertiesTest.java (Tests): Added comprehensive verification tests to ensure that getString, getBoolean, getInt, getStructured, and getStructuredList all return null correctly when a type mismatch occurs.

Verification Results:

All tests in the incubator module passed successfully:

Unit Tests Verification Command: ./gradlew :sdk-extensions:incubator:test ...

Parallel Configuration Cache is an incubating feature.
Reusing configuration cache.

BUILD SUCCESSFUL in 5s
109 actionable tasks: 4 executed, 105 up-to-date
Configuration cache entry reused.

Code Style Check Command: ./gradlew spotlessCheck

Parallel Configuration Cache is an incubating feature.
Calculating task graph as no cached configuration is available for tasks: spotlessCheck

BUILD SUCCESSFUL in 11s
282 actionable tasks: 282 up-to-date
Configuration cache entry stored.

@Bhagirath00 Bhagirath00 requested a review from a team as a code owner February 13, 2026 06:35
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.34%. Comparing base (fff95e0) to head (153c5d1).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...or/fileconfig/YamlDeclarativeConfigProperties.java 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8079      +/-   ##
============================================
+ Coverage     90.20%   90.34%   +0.13%     
+ Complexity     7592     7591       -1     
============================================
  Files           841      839       -2     
  Lines         22911    22838      -73     
  Branches       2288     2280       -8     
============================================
- Hits          20666    20632      -34     
+ Misses         1529     1498      -31     
+ Partials        716      708       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg
Copy link
Member

Verification Results:

No need to bloat the PR description with this type of data which the build checks already tell us ;)

@Bhagirath00 Bhagirath00 force-pushed the fix/declarative-config-no-exceptions branch from 43cad9b to 6eed41c Compare February 15, 2026 11:20
@MikeGoldsmith
Copy link
Member

Docs updates look good. I agree with @robsunday that the EnvironmentGetter/Setter don't need to be in this PR.

@Bhagirath00
Copy link
Author

@robsunday @jack-berg
Addressed review feedback and cleaned up the PR branch.

Copy link
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Look good to me 🚀

Copy link
Contributor

@robsunday robsunday left a comment

Choose a reason for hiding this comment

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

I still have some minor comments, but I approve this PR

@Nullable
@Override
public String getString(String name) {
Objects.requireNonNull(name, "name");
Copy link
Contributor

Choose a reason for hiding this comment

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

The only doubt I have here is that the result of getString(null) will be NPE with quite cryptic message "name".
Maybe the message should be a bit more descriptive? Like "Null configuration property name".
This applies to all changes below.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, updated the message to be more descriptive. Thanks!

* @throws DeclarativeConfigException if the property is not a valid scalar string
* {@code name} has not been configured or is not a valid scalar string
*/
default String getString(String name, String defaultValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency I'd recommend adding here also:
Objects.requireNonNull(defaultValue, "Null default value");

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense, added the null check for defaultValue too.

@Bhagirath00
Copy link
Author

@robsunday Pushed the fixes based on your feedback.

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.

4 participants

Comments