Skip to content

[BUG] ArrayIndexOutOfBoundsException when querying index with disabled objects containing dot-only field names #4896

Closed

Description

@ahkcs

Bug Description

When querying an OpenSearch index that contains documents with field names consisting only of dots (e.g., ".", "..") inside disabled objects ("enabled": false), the SQL plugin throws:

ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

The root cause is in the constructor of OpenSearchExprValueFactory.JsonPath:

public JsonPath(String rawPath) {
  this.paths = List.of(rawPath.split("\\."));
}

When rawPath is ".", the call rawPath.split("\\.") returns an empty array ([]), causing paths.get(0) to fail.


Steps to Reproduce

  1. Create index with disabled object mapping
curl -X PUT "localhost:9200/logs-disabled-test" -H 'Content-Type: application/json' -d '{
  "mappings": {
    "properties": {
      "log": {"type": "object", "enabled": false},
      "@timestamp": {"type": "date"}
    }
  }
}'
  1. Index a document with a dot-only field name
curl -X POST "localhost:9200/logs-disabled-test/_doc" -H 'Content-Type: application/json' -d '{
  "@timestamp": "2025-11-26T17:10:00.000Z",
  "log": {".": "problematic value"}
}'
  1. Run a PPL query
curl -X POST "localhost:9200/_plugins/_ppl" -H "Content-Type: application/json" -d '{
  "query": "source=logs-disabled-test"
}'
  1. Observed result

OpenSearch returns HTTP 500 with an internal exception:

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "java.sql.SQLException: exception while executing query: Index 0 out of bounds for length 0",
    "type": "RuntimeException"
  },
  "status": 500
}

Expected Behavior

The query should:

  1. Either return results successfully, treating "." as a literal field name
  2. Or return a clean, user-facing validation error

The plugin should not crash with an ArrayIndexOutOfBoundsException.


Environment

  • OS: Any
  • OpenSearch Version: 2.19-dev
  • SQL Plugin Version: 2.19-dev (Calcite engine enabled)

Additional Context

This occurs because OpenSearch setting allows arbitrary inner field names for "enabled": false object fields. These documents are indexed without validation. When log pipelines generate malformed keys like ".", they pass through fine, but the SQL plugin fails when trying to parse the field path.

Stack Trace (excerpt)

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at java.base/java.util.ImmutableCollections$ListN.get(ImmutableCollections.java:687)
    at org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory$JsonPath.getRootPath(...)
    at org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory.populateValueRecursive(...)
    ...

Activity

  1. added
    bug
    on Dec 3, 2025
  2. Swiddis commented on Dec 5, 2025

    @Swiddis
    Collaborator

    What's left here after #4907?

  3. added
    error-experience
    on Feb 2, 2026
  4. anasalkouz commented on Feb 26, 2026

    @anasalkouz
    Member

    @ahkcs shall you close the issue? is there anything still pending on this?

  5. ahkcs commented on Feb 26, 2026

    @ahkcs
    CollaboratorAuthor

    Closing this issue as PR merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugerror-experience

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions