Skip to content

Conversation

@EdColeman
Copy link
Contributor

Adds a JSON PropertyType and minimal validation that verifies the property value can be parsed into a JSON object.

This was inspired by issue #3909, but does not directly address it.

  1. Some current properties defer validation until use and this PR does not address that. (That could be done in a follow-on PR)
  2. Some configurations require multiple, independent properties be set for a valid configuration, This PR does not attempt to perform that validation - that responsibility is deferred to the implementations that use those properties.

This implementation was to provide a minimal check, that follow on PRs could extend / leverage to introduce additional property validation.

@EdColeman EdColeman self-assigned this Nov 3, 2023
Copy link
Contributor

@ddanielr ddanielr left a comment

Choose a reason for hiding this comment

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

Overall changes look good. Minor feedback on some tests.

I like jackson's features over GSON and it might be a good change to fully switch over so there's a single JSON parser used in the project.

private static final Logger log = LoggerFactory.getLogger(ConfigSetIT.class);

@Test
public void setInvalidJson() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

This question is probably out of scope of the "simple validation" of this PR.

Is there a way to test setting a custom, user-defined property (created under the general.custom prefix that's of type JSON with the shell?

Copy link
Contributor Author

@EdColeman EdColeman Nov 3, 2023

Choose a reason for hiding this comment

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

As it is now, general.custom is a prefix and does not specify a type.

I think it would take something like a new PREFIX type, maybe something like general.custom.json that could then be used to trigger validation. There may be issues with precedence with general.custom that would short circuit general.custom.json.

Certainly something to discuss as a follow-on.

@EdColeman EdColeman merged commit 1763aa1 into apache:2.1 Nov 15, 2023
@EdColeman EdColeman deleted the 3909_json_property_validation branch November 15, 2023 17:09
@ctubbsii ctubbsii modified the milestones: 3.1.0, 2.1.3 Jul 12, 2024
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