Skip to content

RESTWS-979 - Custom representations are not parsed correctly #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025

Conversation

mseaton
Copy link
Member

@mseaton mseaton commented May 7, 2025

see https://issues.openmrs.org/browse/RESTWS-979

Note, in addition to the unit test included here which demonstrates the issue, I have verified that this also fixes the test that I was attempting to write in EMR API that first caused me to investigate this issue.

@mseaton mseaton requested review from mogoodrich, dkayiwa and ibacher May 7, 2025 16:37
@@ -539,56 +543,46 @@ public static DelegatingResourceDescription getCustomRepresentationDescription(C
String def = representation.getRepresentation();
def = def.startsWith("(") ? def.substring(1) : def;
def = def.endsWith(")") ? def.substring(0, def.length() - 1) : def;
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know where this original code came from - I am shown on the blame in github, but I have no recollection writing this and it doesn't look like my style, so I probably moved it from somewhere and that history is lost.

In any event, this seems to work in some cases (obviously it must), but does not work for certain combinations of nested properties. As can be seen below, the original parsing was pretty brittle, splitting on commas even though commas can be used to separate fields both at the top level and within nested objects, and the code is not resilient to all cases.

Copy link
Member

Choose a reason for hiding this comment

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

I think from the history, you moved it into this class pretty much wholesale from BaseDelegatingResource The bulk of the code is from the initial implementation and then this support for nested properties.

@coveralls
Copy link

coveralls commented May 7, 2025

Coverage Status

coverage: 48.295% (+0.06%) from 48.237%
when pulling 3741f4b on RESTWS-979
into 212781d on master.

Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -539,56 +543,46 @@ public static DelegatingResourceDescription getCustomRepresentationDescription(C
String def = representation.getRepresentation();
def = def.startsWith("(") ? def.substring(1) : def;
def = def.endsWith(")") ? def.substring(0, def.length() - 1) : def;
Copy link
Member

Choose a reason for hiding this comment

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

I think from the history, you moved it into this class pretty much wholesale from BaseDelegatingResource The bulk of the code is from the initial implementation and then this support for nested properties.

@dkayiwa
Copy link
Member

dkayiwa commented May 7, 2025

Very interesting that for all these years we have never got a problem with this. 😊

@mseaton mseaton merged commit e17c11e into master May 7, 2025
1 check passed
@mseaton mseaton deleted the RESTWS-979 branch May 7, 2025 22:17
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.

5 participants