Commit 30af8b2
authored
[BugFix] Handle opaque NullPointerException for unresolvable alias-type field path (#5536)
* Fix opaque NullPointerException for unresolvable alias-type field path
When a mapping contains a field of "type": "alias" whose "path" points to
a target absent from the flattened mapping (a text multi-field such as
field.keyword, or a removed/renamed field), validateAliasType passed a null
target into the OpenSearchAliasType constructor, which dereferenced it at
super(type.getExprCoreType()) and surfaced an opaque NullPointerException.
Guard the null target and throw a SemanticCheckException naming the alias
field and its unresolved path. SemanticCheckException extends
QueryEngineException, so JdbcResponseFormatter maps it to HTTP 400 (client
error) rather than the misleading 500 a generic exception would produce.
Add unit tests covering the .keyword multi-field and missing-field cases.
Fixes #5535
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
* Add integration test and trim unit-test comments for alias path fix
Add a QueryValidationIT case asserting that SELECT * over an index whose
alias field targets a text multi-field (source.keyword) returns a 400
SemanticCheckException with the descriptive message. An alias pointing at a
truly missing field is rejected by OpenSearch at index-creation time, so it
is not reachable through the SQL plugin and is covered by the unit test only.
Shorten the unit-test comments and drop inline issue references.
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
* Apply spotless formatting
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
* Adopt ErrorReport for unresolvable alias path error
Wrap the SemanticCheckException in an ErrorReport (the report-builder
interface from #5266) so the error carries structured context as it bubbles
up: FIELD_NOT_FOUND code, ANALYZING stage, a location chain, the alias field
and path as context, and a fix suggestion. On the PPL/Calcite path this
renders as a rich structured error; on the SQL JDBC path it still returns a
clear 400 (RestSqlAction unwraps to the SemanticCheckException cause), though
the JdbcResponseFormatter does not yet render the ErrorReport structure.
Update the unit test to assert the ErrorReport code/stage/context/cause, the
SQL IT for the ErrorReport type, and add a PPL IT asserting the structured
FIELD_NOT_FOUND error in CalciteErrorReportStageIT.
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
---------
Signed-off-by: Jialiang Liang <jiallian@amazon.com>1 parent 8394e5c commit 30af8b2
4 files changed
Lines changed: 133 additions & 1 deletion
File tree
- integ-test/src/test/java/org/opensearch/sql
- calcite/remote
- sql
- opensearch/src
- main/java/org/opensearch/sql/opensearch/data/type
- test/java/org/opensearch/sql/opensearch/data/type
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
217 | 250 | | |
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
106 | 131 | | |
107 | 132 | | |
108 | 133 | | |
| |||
Lines changed: 24 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
300 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
301 | 324 | | |
302 | 325 | | |
303 | 326 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
483 | 487 | | |
484 | 488 | | |
485 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
486 | 537 | | |
487 | 538 | | |
488 | 539 | | |
| |||
0 commit comments