Skip to content

Add a new schema checker option - #301

Closed
kolehey wants to merge 1 commit into
masterfrom
DS-51562-allow-obj-val-str-sub-attrs
Closed

Add a new schema checker option#301
kolehey wants to merge 1 commit into
masterfrom
DS-51562-allow-obj-val-str-sub-attrs

Conversation

@kolehey

@kolehey kolehey commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Added a new ALLOW_OBJECT_VALUED_STRING_SUB_ATTRIBUTES schema checker option to allow string-type sub-attributes whose value is a json object.

Reviewer: kqarryzada
Reviewer: dougbulkley

JiraIssue: DS-51562

@kolehey kolehey self-assigned this Jun 16, 2026
Added a new ALLOW_OBJECT_VALUED_STRING_SUB_ATTRIBUTES schema
checker option to allow string-type sub-attributes whose value
is a json object.

Reviewer: kqarryzada
Reviewer: dougbulkley

JiraIssue: DS-51562
@kolehey
kolehey force-pushed the DS-51562-allow-obj-val-str-sub-attrs branch from 6722cd7 to 3c32a75 Compare June 16, 2026 19:01

@kqarryzada kqarryzada left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks good to me. I had some minor comments.

* Per RFC 7643, complex sub-attributes are not supported; this option
* relaxes that constraint for non-conformant resources.
*/
ALLOW_OBJECT_VALUED_STRING_SUB_ATTRIBUTES

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should have a comma at the end.

{
if (enabledOptions.contains(
Option.ALLOW_OBJECT_VALUED_STRING_SUB_ATTRIBUTES)
&& node.isObject() && path.size() > 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The node type is checked twice, which we can avoid (along with the copied code) by rewriting this with the following. I also think we can rename the option:

case STRING:
  if (node.isObject() && path.size() > 1
    && enabledOptions.contains(Option.ALLOW_OBJECT_AS_STRING_SUB_ATTR))
  {
    return;
  }

  // Fall through for string evaluation.
case DATETIME:
...

// Build a schema with a complex parent attribute whose sub-attribute is
// STRING-typed but stores a JSON object value.
AttributeDefinition.Builder builder = new AttributeDefinition.Builder();
builder.setName("iamSvcUsrData");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The old tests don't do this much, but we should leverage the builder pattern on this:

AttributeDefinition.Builder builder = new AttributeDefinition.Builder()
    .setName(...)
    .setType(...)

assertEquals(results.getSyntaxIssues().size(), 1,
results.getSyntaxIssues().toString());
assertTrue(containsIssueWith(results.getSyntaxIssues(),
"must be a JSON string"));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

New unit tests should use AssertJ's assertion statements instead of TestNG's. For example, this should be:

assertThat(results.getSyntaxIssues()).hasSize(1);
assertThat(results.getSyntaxIssues().get(0))
    .contains("must be a JSON string");

For assertion statements that currently have a reason string, you can use .as() if you really want, but I think it's also okay to drop them from this test.


List<PatchOperation> patchOps = Collections.singletonList(
PatchOperation.replace(
Path.root().attribute("iamServiceUser"), iamServiceUserNode));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you want, this can use the string attribute directly since the method throws an exception.

@kolehey kolehey closed this Jun 18, 2026
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.

2 participants