Serialization fix when the expected type is PluginConfigVariable#5698
Merged
Conversation
Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com>
dlvenable
requested changes
May 16, 2025
| // which is not of a secrets expression that we would check (filter check above fails) but | ||
| // still expects an instance of PluginConfigVariable object returned | ||
| if (destinationType.equals(PluginConfigVariable.class)) { | ||
| return destinationType.cast(new PluginConfigVariable() { |
Member
There was a problem hiding this comment.
Rather than make an anonymous class, the code would be readable if you make a static inner class.
private static ImmutablePluginConfigVariable {
private final Object rawValue;
ImmutablePluginConfigVariable(Object rawValue) { ... }
// similar code
}
Collaborator
Author
There was a problem hiding this comment.
Moved to an private static immutable class for better readability
| objectUnderTest = new VariableExpander(OBJECT_MAPPER, Set.of(pluginConfigValueTranslator)); | ||
| final Object actualResult = objectUnderTest.translate(jsonParser, PluginConfigVariable.class); | ||
| assertNotNull(actualResult); | ||
| assertInstanceOf(PluginConfigVariable.class, actualResult); |
Member
There was a problem hiding this comment.
You should have assertions on getValue, and isUpdatable, etc.
Collaborator
Author
There was a problem hiding this comment.
Yes, added additional assertions
|
|
||
| @Override | ||
| public void setValue(Object updatedValue) { | ||
|
|
Member
There was a problem hiding this comment.
Should we throw new UnsupportedOperationException()?
dlvenable
requested changes
May 16, 2025
|
|
||
| @Test | ||
| void testTranslateJsonParserWithSPluginConfigVariableValue_when_non_secret_format_is_given() throws IOException { | ||
| final String testSecretReference = "not-in-aws-secrets-expression-format"; |
Member
There was a problem hiding this comment.
Use a random UUID here. Also, this code should be generic beyond just AWS Secrets as it is part of core.
Collaborator
Author
There was a problem hiding this comment.
Using random value now
Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com>
Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com>
chenqi0805
approved these changes
May 16, 2025
dlvenable
approved these changes
May 17, 2025
alparish
pushed a commit
to alparish/data-prepper
that referenced
this pull request
May 22, 2025
…nsearch-project#5698) * Serialization fix when the expected type is PluginConfigVariable
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
Current logic is expecting the rawSecret value to be of a certain format to be able to convert to PluginConfigVariable type. But then the requested type is PluginConfigVariable but raw value is not passing the expression format check filter criteria, we are currently failing to serialize the value into the object type. This fix is to still return an instance of a requested type without any attached functionality. We will be avoiding the serialization issue with this fix.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.