[dynamic control] fix incorrectly special case parsing#3010
Open
jackshirazi wants to merge 3 commits into
Open
[dynamic control] fix incorrectly special case parsing#3010jackshirazi wants to merge 3 commits into
jackshirazi wants to merge 3 commits into
Conversation
25 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors dynamic-control policy payload parsing so providers always delegate parsing to SourceFormat (removing an OpAMP-specific JSON parsing fallback), and updates the JSON parsing path to validate policy IDs against configured mappings.
Changes:
- Extend
SourceFormat.parse/JsonSourceWrapper.parseto accept amappedPolicyIdsset and use it during parsing (JSONKEYVALUE). - Remove
OpampPolicyProvider’s JSONKEYVALUE special-case parsing logic and delegate parsing solely toSourceFormat. - Update unit tests and the file-based provider to pass mapped/allowed policy IDs into the parser.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/SourceFormat.java | Changes the parsing API to require mapped policy IDs and dispatches parsing with that context. |
| dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapper.java | Updates JSON parsing to validate JSON object keys against configured mapped policy IDs. |
| dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/OpampPolicyProvider.java | Removes OpAMP-only JSONKEYVALUE fallback parsing and delegates parsing to SourceFormat. |
| dynamic-control/src/main/java/io/opentelemetry/contrib/dynamic/policy/LinePerPolicyFileProvider.java | Computes allowed policy IDs from validators and passes them into SourceFormat.parse. |
| dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/SourceFormatTest.java | Updates tests for the new parse signature + adds coverage for rejecting unmapped JSON keys. |
| dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/source/JsonSourceWrapperTest.java | Updates tests for the new parse signature + adds coverage for rejecting unmapped JSON keys. |
| dynamic-control/src/test/java/io/opentelemetry/contrib/dynamic/policy/tracesampling/TraceSamplingValidatorTest.java | Updates tests to provide mapped policy IDs when parsing source text. |
LikeTheSalad
approved these changes
Jul 22, 2026
jaydeluca
reviewed
Jul 22, 2026
| return; | ||
| } | ||
| List<SourceWrapper> parsedSources = format.parse(trimmedLine); | ||
| List<SourceWrapper> parsedSources = format.parse(trimmedLine, policyIds); |
Member
There was a problem hiding this comment.
i think we lose some safety here in terms of rejecting objects with more than 1 item. Take a look at jackshirazi#1
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:
There was a special case parsing in OpampPolicyProvider,
if ( ... format == SourceFormat.JSONKEYVALUE), on reviewing the code this clearly shouldn't be there, any parsing should exist within the format parsing and the provider should delegate all cases to there. This PR fixes this code smell.Note the
LinePerPolicyFileProvider.javaand thekeyvalueformat are not fully implemented for now, they're pending later changes when the file provider is more fully specifiedExisting Issue(s):
#2868
Testing:
changed as needed
Documentation:
not needed for this tech debt fix
Outstanding items:
#2868