csv-validator icon indicating copy to clipboard operation
csv-validator copied to clipboard

Using an invalid column reference as a string provider does not produce a helpful error message

Open DavidUnderdown opened this issue 9 years ago • 7 comments

If a column expression uses an invalid column reference as a string provider the CSV Validator returns a Java null pointer exception, rather than an error message that explains that the column reference is invalid. eg if there is resource_uri column then doing in($resource_uri) in another column doesn't produce a useful error message, so it can be very hard to track down the problem in the schema (should this be checked when the schema is parsed?). Should also check what happens if this was used in an explicit context expression

DavidUnderdown avatar Jun 21 '16 15:06 DavidUnderdown

A big omission from the CSV Schema spec is error conditions. Ideally there should be a code defined in the spec for each class of error, if you did that, we could implement that. The W3C XPath and XQuery specs are a useful example of a spec which defines error codes.

adamretter avatar Jun 21 '16 18:06 adamretter

we define broadly the concept of schema errors v validation errors (and warnings), though admittedly this type of column name reference error is not included in the examples given for schema errors.

I can look at at least tightening those definitions up a little for 1.2

DavidUnderdown avatar Jun 22 '16 08:06 DavidUnderdown

On a related note, if an incorrect column reference is used within a concat, this does not produce a Java null pointer exception, but the test simply fails. As the error report does not show the values from the referenced columns it can be hard to work out where there is an error as manually comparing the columns it is difficult to see why the concatenated value does not match as expected.

DavidUnderdown avatar Aug 25 '16 15:08 DavidUnderdown

This is actually probably a duplicate to #118

DavidUnderdown avatar Feb 22 '18 13:02 DavidUnderdown

I'm seeing 'invalid cross reference' as the error given. This seems pretty good to me?

Though I do also get the unhelpful message described when using concat...

luketebbs avatar Mar 10 '22 08:03 luketebbs

That generally seems OK, but would be good to fix in the case of concat too

DavidUnderdown avatar Mar 10 '22 10:03 DavidUnderdown

https://github.com/digital-preservation/csv-validator/pull/362

luketebbs avatar Mar 27 '22 18:03 luketebbs