Skip to content

[#212] Write an attribute given in another case under the schema's name, and refuse one given twice, in create and update - #217

Merged
maximthomas merged 5 commits into
OpenIdentityPlatform:masterfrom
maximthomas:issues/212-xml-attribute-name-case
Nov 2, 2026
Merged

maximthomas merged 5 commits into
OpenIdentityPlatform:masterfrom
maximthomas:issues/212-xml-attribute-name-case

Conversation

@maximthomas

@maximthomas maximthomas commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #212.

The framework compares attribute names without regard to case, and checkAttribute (#192) looks a given attribute up in the schema the same way. Everything after that lookup used the caller's spelling, while the XSD and the file name attributes exactly:

  • create kept the checked values under the given spelling. Its required-attribute pass and its write go through the schema's attributes, so they missed LastName: a required attribute failed with No values provided for required attribute: lastname, an optional one was written as an empty element. Its __NAME__ check was an exact containsKey, so __name__ alone got __NAME__ must be defined.
  • update removed and wrote elements under the given spelling. LastName=X left <ri:lastname> as it was and appended <ri:LastName>X</ri:LastName>. __password__ appended an element and left the password unchanged. __name__ skipped the taken-name check and left the entry's name unchanged.
  • The messages named the attribute as given.

Now checkAttribute returns the attribute under the schema's name, CheckedAttribute(attributeInfo.getName(), values), and every later step uses that name: the __NAME__ rules, the messages, create's required pass and write, and update's taken-name check, removal and write. It looks the given name up exactly first, and without regard to case only when the schema has no attribute of exactly that name. An XSD may declare two names that differ only in case, such as lastname and LastName, and the framework's case-insensitive map holds one of the two for both names; the exact lookup keeps them apart. Data field: X is not supported. keeps the given spelling, as the schema has none. create finds __NAME__ with AttributeUtil.find, which ignores case, and takes the name from the checked values. It no longer calls AttributeUtil.getNameFromAttributes, which casts the attribute to Name; only an exact __NAME__ is a Name, so __name__ would throw ClassCastException there.

A new checkAttributes runs checkAttribute over the given set, in order, and refuses a schema attribute given more than once in any spelling: Data field: lastname is given more than once, as lastname and as LastName. A Set<Attribute> can hold such a pair, because Attribute.hashCode ignores case while equals compares the values too; it can even hold exactly one name twice with different values. Neither value is surely the one meant, so the pair is refused rather than resolved by the order of the set. The framework's CreateImpl refuses only exactly one name given twice, and UpdateImpl neither. Both operations use the helper, so the refusal comes before any change to the document.

Changes in behaviour

  • An attribute whose name differs from the schema's only in case is checked, written and reported under the schema's name, in create and in update. create with LastName and no lastname succeeds. __name__ renames the entry and is checked for a clash. __password__ replaces the stored password.
  • Every message of checkAttribute except Data field: X is not supported. names the attribute as the schema spells it. For example, IS-DELETED=true in update now gets is-deleted is not updatable., not IS-DELETED is not updatable.
  • A schema attribute given more than once, in any spelling, gets an IllegalArgumentException with the message above, and nothing changes. Before, create either kept one of the values or, for [LastName, lastname], refused the request as missing lastname; update applied both attributes, in order.
  • update checks whether a new __NAME__ is taken only after every given attribute has passed its checks, as create does. A taken name together with a bad attribute now gets the IllegalArgumentException about the attribute instead of AlreadyExistsException.
  • An OpenIDM PATCH with two operations of one kind on one attribute now fails with Data field: lastname is given more than once, as lastname and as lastname. OpenIDM's provisioner turns each operation into its own attribute, so two replace operations on /lastname reach update as lastname given twice. Before, the last one won: of two replace operations the second was written, and of two add operations on a multi-valued attribute the first new value was lost. This was traced through OpenIDM's and the framework's code, not run.
  • On an XSD with two attribute names that differ only in case, create given both writes each value into its own element. Before, it wrote the second value into the element spelled like the first name given, and left the other element empty.

Tests

  • XMLHandlerReloadTests#createWritesAnAttributeUnderTheSchemaName and #updateWritesAnAttributeUnderTheSchemaName give LastName, FirstName, __name__ and a guarded __password__, and check the file: the schema's element holds the value, and no element has the given spelling. Reads skip empty elements, so a search would not show a stray or empty element.
    • On master, create refuses LastName (No values provided for required attribute: lastname), __name__ (__NAME__ must be defined.) and __password__ (No values provided for required attribute: __PASSWORD__), and writes an empty firstname.
    • On master, update leaves lastname, firstname, __NAME__ and __PASSWORD__ as they were.
  • XMLHandlerReloadTests#renameIntoATakenNameLeavesTheEntryAndTheFileAlone runs with __NAME__ and with __name__. On master the __name__ row is not refused.
  • XMLHandlerReloadTests#renameIntoATakenNameWithABadAttributeIsRefusedForTheAttribute gives update a taken __NAME__ first and an attribute the schema does not have second. It expects Data field: no-such-attribute is not supported. and an unchanged file. On master it gets AlreadyExistsException.
  • XMLHandlerReloadTests#createAndUpdateRefuseAnAttributeAlike gets four rows in another case: a valueless LastName, a blank LASTNAME, LastName=["A", "B"] and a blank __name__. Each expects the message in the schema's spelling from both operations. On master the messages name LastName or LASTNAME, and create refuses the blank __name__ with __NAME__ must be defined. The row's attribute now replaces the new account's attribute of the same name in any case, not only in exactly the same case.
  • XMLHandlerReloadTests#rejectedUpdateLeavesTheEntryAndTheFileAlone gets an IS-DELETED=true row that expects is-deleted is not updatable.
  • XMLHandlerReloadTests#createRefusesAttributesWithoutAName gives create null, then a set whose only name is a valueless __name__, then one whose only name is __name__ with an empty list. All three expect __NAME__ must be defined. All three pass on master. Without the null check on the value of the attribute that AttributeUtil.find returns, the second gets a NullPointerException; without the isEmpty check, the third gets No values provided for required attribute: __NAME__.
  • XMLHandlerIndexTests#attributesWhoseNamesDifferOnlyInCaseAreWrittenApart copies the test XSD with an optional LastName next to the required lastname. It creates an account with both and updates another with both, and expects each value in its own element. Without the exact lookup, both operations refuse the pair as given twice. On master create writes Other-carol into <ri:lastname> and leaves <ri:LastName> empty.
  • XMLHandlerIndexTests#clearingAnOptionalNameIsRefused now also clears the name with __name__, on a schema where __NAME__ is optional, and expects Parameter '__NAME__' must not be blank. On master nothing is thrown. The test also fails if checkAttribute compares the given name instead of the schema's with __NAME__.
  • XMLHandlerReloadTests#createAndUpdateRefuseAnAttributeGivenTwice gives [lastname, LastName], [LastName, lastname], [email=a, email=b] and [__NAME__, __name__] to create, inside a valid new account, and to update. It expects the duplicate message from both, with the file and the entry in memory unchanged. On master create accepts three of the pairs and refuses [LastName, lastname] as missing lastname, and update accepts all four.
  • Removed, as they pinned the behaviour this replaces:
    • createKeepsOneOfTwoSameNamedAttributes: create kept email=b of email=a and email=b.
    • repeatedAttributeKeepsTheLastValue: update applied lastname=A, then lastname=B.
    • The LASTNAME row of createRefusesAMissingRequiredAttribute.
  • XMLFilterTranslatorTests.setUpClass gave its first account email as two attributes, which create now refuses. It now gives one email attribute with both values. No test of the class reads them.

These tests were run against master's XMLHandlerImpl: 21 runs fail, all of them named above. The module runs 386 tests with no failures, 366 on master.

Not covered

  • Elements such as <ri:LastName> that the old code wrote into existing files stay there, as update removes only the element the schema spells. Reads skip them. A filter, though, names the element as it spells the attribute, so LastName=X still finds an entry by its stray <ri:LastName>X</ri:LastName>, and finds none by the lastname the new code writes. A filter in another case than the schema's misses schema-spelled elements on master too: XML connector: a filter on an attribute name in another case than the schema's finds nothing #218.
  • On an XSD with two attribute names that differ only in case, a name in a third spelling, such as LASTNAME next to lastname and LastName, goes to whichever of the two the framework's case-insensitive map holds. Reads return only one of the two, as before.

@maximthomas maximthomas added bug Something isn't working java Pull requests that update java code tests Test additions or fixes connector:xml XML connector data-loss Fixes or risks loss or corruption of stored data labels Nov 2, 2026
…e first, so an XSD with two names that differ only in case keeps both apart
…ate's empty-name check; note how create refuses a valueless second name

@vharseko vharseko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed at e22ced1. I found no new issues in the changes.

create and update resolve supplied names to the schema spelling before applying them, and reject repeated attributes before changing the document. The exact-name lookup also preserves the distinction between schema attributes whose names differ only in case.

The remaining case-sensitive filter behavior and the treatment of elements previously written under another spelling are documented in the PR description and tracked in #218.

I did not run the tests locally. CodeQL passed; the Maven CI jobs were still pending when I checked.

@maximthomas
maximthomas merged commit a56dfcf into OpenIdentityPlatform:master Nov 2, 2026
15 checks passed
@maximthomas
maximthomas deleted the issues/212-xml-attribute-name-case branch November 2, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connector:xml XML connector data-loss Fixes or risks loss or corruption of stored data java Pull requests that update java code tests Test additions or fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XML connector: create and update accept an attribute name in another case, then lose its value

2 participants