Skip to content
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

RELAX NG Invalid value for regex - error message lists regexes in random order #247

Open
walmsleyph opened this issue Jan 31, 2019 · 1 comment

Comments

@walmsleyph
Copy link

walmsleyph commented Jan 31, 2019

This is a really minor issue, but when a datatype lists multiple possible regexes, and Jing correctly reports that a value is invalid, it lists all the regexes but in random order. For example, the error message might be

value of attribute "x" is invalid; must be a string matching the regular expression "a", must be a string matching the regular expression "b" or must be a string matching the regular expression "c"

one time, but then the next time it lists them in c, b, a order.

It's a minor thing, but it is wreaking havoc with our regression tests that are looking for a specific error message. It would be great if they could be in the order they are listed in the RELAX NG schema, which is probably the most logical.

@sideshowbarker
Copy link
Contributor

If you could provide a test case I can use to reproduce the problem, that’s be super great.

I think the code that’s composing the content of that error message is here:

if (stringValues.size() > 0) {
Collections.sort(stringValues);
for (int i = 0; i < stringValues.size(); i++)
stringValues.set(i, quoteValue(stringValues.get(i)));
messages.add(localizer().message("require_values",
formatList(stringValues, "or")));

…but without having a test case or constructing one, we can’t really know for sure and can’t do much specific troubleshooting to isolate the cause of the random ordering.

As you can in that code snippet, Collections.sort(stringValues) is getting called on what I think is the list of string that are getting emitted in the error message you’re seeing. So I would assume that ought to be putting the message strings into the same order each time. But despite that sort(…), clearly in the end the strings are not actually ending up in the same order each time. Or else my assumption about the relevant part of the code is wrong…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants