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

Update DefaultTAPErrorWriter.java #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

denaliak
Copy link

TAP service returns an invalid error document, which is not parsable.

When running the TAP query with a syntax error in 'async' mode, e.g. "SELECT TOP 1000 FROM TAP_SCHEMA.schemas" (missing ''), The error page created would include two INFO element, namely, 'CAUSES' and 'ORIGIN_STACK_TRACE', as follows:

- Encountered "FROM". Was expecting one of: "(" "+" "-" "
" "AVG" "MAX" "MIN" "SUM" "COUNT" "BOX" "CENTROID" "CIRCLE" "POINT" "POLYGON" "REGION" "CONTAINS" "INTERSECTS" "AREA" "COORD1" "COORD2" "COORDSYS" "DISTANCE" "ABS" "CEILING" "DEGREES" "EXP" "FLOOR" "LOG" "LOG10" "MOD" "PI" "POWER" "RADIANS" "RAND" "ROUND" "SQRT" "TRUNCATE" "ACOS" "ASIN" "ATAN" "ATAN2" "COS" "COT" "SIN" "TAN" "'" <SCIENTIFIC_NUMBER> <UNSIGNED_FLOAT> <UNSIGNED_INTEGER> """ <REGULAR_IDENTIFIER_CANDIDATE> <REGULAR_IDENTIFIER_CANDIDATE> """
(HINT: "FROM" is a reserved ADQL word. To use it as a column/table/schema name/alias, write it between double quotes.)


adql.parser.ParseException: Encountered "FROM". Was expecting one of: "(" "+" "-" "*" "AVG" "MAX" "MIN" "SUM" "COUNT" "BOX" "CENTROID" "CIRCLE" "POINT" "POLYGON" "REGION" "CONTAINS" "INTERSECTS" "AREA" "COORD1" "COORD2" "COORDSYS" "DISTANCE" "ABS" "CEILING" "DEGREES" "EXP" "FLOOR" "LOG" "LOG10" "MOD" "PI" "POWER" "RADIANS" "RAND" "ROUND" "SQRT" "TRUNCATE" "ACOS" "ASIN" "ATAN" "ATAN2" "COS" "COT" "SIN" "TAN" "'" <SCIENTIFIC_NUMBER> <UNSIGNED_FLOAT> <UNSIGNED_INTEGER> """ <REGULAR_IDENTIFIER_CANDIDATE> <REGULAR_IDENTIFIER_CANDIDATE> """
(HINT: "FROM" is a reserved ADQL word. To use it as a column/table/schema name/alias, write it between double quotes.)
at adql.parser.ADQLParser.generateParseException(ADQLParser.java:6320)
at adql.parser.ADQLParser.jj_consume_token(ADQLParser.java:6180)
at adql.parser.ADQLParser.SelectItem(ADQLParser.java:1318)
at adql.parser.ADQLParser.Select(ADQLParser.java:1162)
at adql.parser.ADQLParser.QueryExpression(ADQLParser.java:1051)
at adql.parser.ADQLParser.Query(ADQLParser.java:1010)
at adql.parser.ADQLParser.parseQuery(ADQLParser.java:451)
at tap.ADQLExecutor.parseADQL(ADQLExecutor.java:571)
at tap.ADQLExecutor.start(ADQLExecutor.java:366)
at tap.ADQLExecutor.start(ADQLExecutor.java:226)
at tap.AsyncThread.jobWork(AsyncThread.java:81)
at uws.job.JobThread.run(JobThread.java:430)

These two INFO elements contain free text that is not parsable by the xml parser, resulting in an error. You can try this out on TOPCAT.
The error I am getting from the parser is
The element type "REGULAR_IDENTIFIER" must be terminated by the matching end-tag "</REGULAR_IDENTIFIER>".

To fix it, CDATA (Character Data that should not be interpreted as XML markup) should be used around all free text:

or whatever ]]>

TAP service returns an invalid error document, which is not parsable.

When running the TAP query with a syntax error in 'async' mode, e.g. "SELECT TOP 1000 FROM TAP_SCHEMA.schemas" (missing '*'), The error page created would include two INFO element, namely, 'CAUSES' and 'ORIGIN_STACK_TRACE', as follows:
<INFO  name="CAUSES" value="1">
        -  Encountered "FROM". Was expecting one of: "(" "+" "-" "*" "AVG" "MAX" "MIN" "SUM" "COUNT" "BOX" "CENTROID" "CIRCLE" "POINT" "POLYGON" "REGION" "CONTAINS" "INTERSECTS" "AREA" "COORD1" "COORD2" "COORDSYS" "DISTANCE" "ABS" "CEILING" "DEGREES" "EXP" "FLOOR" "LOG" "LOG10" "MOD" "PI" "POWER" "RADIANS" "RAND" "ROUND" "SQRT" "TRUNCATE" "ACOS" "ASIN" "ATAN" "ATAN2" "COS" "COT" "SIN" "TAN" "\'" <SCIENTIFIC_NUMBER> <UNSIGNED_FLOAT> <UNSIGNED_INTEGER> "\"" <REGULAR_IDENTIFIER_CANDIDATE> <REGULAR_IDENTIFIER_CANDIDATE> "\""
(HINT: "FROM" is a reserved ADQL word. To use it as a column/table/schema name/alias, write it between double quotes.)
</INFO>
<INFO  name="ORIGIN_STACK_TRACE" value="2">
adql.parser.ParseException:  Encountered "FROM". Was expecting one of: "(" "+" "-" "*" "AVG" "MAX" "MIN" "SUM" "COUNT" "BOX" "CENTROID" "CIRCLE" "POINT" "POLYGON" "REGION" "CONTAINS" "INTERSECTS" "AREA" "COORD1" "COORD2" "COORDSYS" "DISTANCE" "ABS" "CEILING" "DEGREES" "EXP" "FLOOR" "LOG" "LOG10" "MOD" "PI" "POWER" "RADIANS" "RAND" "ROUND" "SQRT" "TRUNCATE" "ACOS" "ASIN" "ATAN" "ATAN2" "COS" "COT" "SIN" "TAN" "\'" <SCIENTIFIC_NUMBER> <UNSIGNED_FLOAT> <UNSIGNED_INTEGER> "\"" <REGULAR_IDENTIFIER_CANDIDATE> <REGULAR_IDENTIFIER_CANDIDATE> "\""
(HINT: "FROM" is a reserved ADQL word. To use it as a column/table/schema name/alias, write it between double quotes.)
        at adql.parser.ADQLParser.generateParseException(ADQLParser.java:6320)
        at adql.parser.ADQLParser.jj_consume_token(ADQLParser.java:6180)
        at adql.parser.ADQLParser.SelectItem(ADQLParser.java:1318)
        at adql.parser.ADQLParser.Select(ADQLParser.java:1162)
        at adql.parser.ADQLParser.QueryExpression(ADQLParser.java:1051)
        at adql.parser.ADQLParser.Query(ADQLParser.java:1010)
        at adql.parser.ADQLParser.parseQuery(ADQLParser.java:451)
        at tap.ADQLExecutor.parseADQL(ADQLExecutor.java:571)
        at tap.ADQLExecutor.start(ADQLExecutor.java:366)
        at tap.ADQLExecutor.start(ADQLExecutor.java:226)
        at tap.AsyncThread.jobWork(AsyncThread.java:81)
        at uws.job.JobThread.run(JobThread.java:430)

</INFO>

These two INFO elements contain free text that is not parsable by the xml parser, resulting in an error. You can try this out on TOPCAT.
The error I am getting from the parser is  
 The element type "REGULAR_IDENTIFIER" must be terminated by the matching end-tag "</REGULAR_IDENTIFIER>".

To fix it, CDATA (Character Data that should not be interpreted as XML markup) should be used around all free text:

<![CDATA[
free text with <REGULAR_IDENTIFIER>  or whatever
]]>
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.

1 participant