oracle / oracle/nosql-java-sdk

Improve Error Messages for Query Syntax Issues in Oracle NoSQL Database

Open
#138 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
34
Forks
27
Avg merge
13h 59m
Merged PRs (30d)
2

Description

When executing a query with a syntax issue, the error message provided does not clearly indicate where the problem lies. Instead, it returns a generic message that can be misleading and does not help pinpoint the exact issue.

Example

Consider the following query:

DELETE FROM entity WHERE entity = 'Drink' AND BETWEEN content.alcoholPercentage ? AND ?

The query fails with the following error message:

java.lang.IllegalArgumentException: PREPARE: Illegal Argument: Table, index and unquoted field names may contain only alphanumeric values plus the character "_". Error: at (1, 80) mismatched input 'entity' expecting {<EOF>, AND, IS, OR, RETURNING, '[', '*', '.', '<', '<=', '>', '>=', '=', '!=', LT_ANY, LTE_ANY, GT_ANY, GTE_ANY, EQ_ANY, NEQ_ANY, '+', '-', '/', RDIV, '||'}, at line 1:80
rule stack: [parse]

This message suggests that the issue is with the field reference syntax (e.g., the use of .), but that is the correct way to navigate JSON fields. The issue is with the incorrect placement of the BETWEEN clause.

Correct Query

The correct syntax for this query is:

DELETE FROM entity WHERE entity = 'Drink' AND content.alcoholPercentage BETWEEN ? AND ?

When the query is written this way, it executes successfully.

Suggested Enhancement

The error message should be more descriptive and guide the user in identifying the actual issue. Instead of providing a generic error like:

mismatched input 'entity' expecting ...

It could suggest specific query syntax rules that might be violated or point to possible misplacements like:

  • "Syntax error: Check the placement of the BETWEEN clause."
  • "Unexpected token 'BETWEEN'. Ensure it is correctly structured as <field> BETWEEN <value> AND <value>."

Improving error messages will significantly enhance the developer experience by reducing confusion and helping quickly identify issues.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points; start by locating the query parser and the code that formats syntax errors in the Java SDK. Reproduce the shown DELETE query and compare its diagnostic with the corrected query, then define tests that verify the reported location and guidance are accurate without misidentifying JSON field syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.