apache / apache/druid

Confusing error for a missing query parameter

Open
#13,768 0 comments 0 reactions 0 assignees View on GitHub
Error handling
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

Please provide a detailed title (e.g. "Broker crashes when using TopN query with Bound filter" instead of just "Broker crashes").

### Affected Version

26.0.0-SNAPSHOT

### Description

Suppose we submit a query that takes a query parameter, but we omit the parameter in the request. We get back a misleading error. Please provide a better error messages.

Query:

```sql
REPLACE INTO "myWiki" OVERWRITE ALL
SELECT
TIME_PARSE("timestamp") AS "__time",
namespace,
page,
channel,
"user",
countryName,
CASE WHEN isRobot = 'true' THEN 1 ELSE 0 END AS isRobot,
"added",
"delta",
CASE WHEN isNew = 'true' THEN 1 ELSE 0 END AS isNew,
"deltaBucket",
"deleted"
FROM TABLE(ext.wikiSample(
uris => ?
))
```

The error response:

```
{'error': 'Plan validation failed',
'errorMessage': 'At line 17, column 11: Illegal use of dynamic parameter',
'errorClass': 'org.apache.calcite.tools.ValidationException',
'host': None}
```

Note that the _use_ of the dynamic parameter is legal. Rather, the problem is that no value was provided. So, the error should be "No value provided for parameter 1."

Suppose we simplify the query as the above query depends on a catalog definition, and does some fancy stuff irrelevant to this issue. So, let's try a very simple query:

```sql
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ?
```

In this case, we get a non-error response with no data. Yet, we didn't provide query parameter values. Same situation, different outcome. Still confusing.

The request is to have a consistent error message when the number of query parameters and values don't match.

Contributor guide

Open the contributing guide

Research direction

Start by tracing validation of missing query parameters in the two SQL examples and compare why they produce different outcomes. Done means requests whose parameter and value counts do not match consistently return a clear error such as "No value provided for parameter 1."

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.