Skip to content

[Enhancement] Reject unsupported output formats on the analytics-engine route with a 4xx#5570

Merged
RyanL1997 merged 2 commits into
opensearch-project:mainfrom
RyanL1997:fix/ae-reject-unsupported-format
Jun 19, 2026
Merged

[Enhancement] Reject unsupported output formats on the analytics-engine route with a 4xx#5570
RyanL1997 merged 2 commits into
opensearch-project:mainfrom
RyanL1997:fix/ae-reject-unsupported-format

Conversation

@RyanL1997

@RyanL1997 RyanL1997 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Description

The analytics-engine (Calcite/DataFusion) route formats every response with SimpleJsonResponseFormatter and does not implement the alternate response formats (csv/raw/viz) that the classic SQL/PPL engines support. A request such as format=csv against an analytics index was silently answered with JSON: the client asked for one content type and received another, with no signal that the parameter was dropped.

This PR adds an up-front guard on the analytics route that rejects an unsupported output format with a structured ErrorReport coded UNSUPPORTED_OPERATION, so the client gets a clean 4xx with an actionable message instead of silent JSON. JSON/JDBC (the default) is unaffected.

Changes

  • New AnalyticsEngineFormatSupport.validateFormat(Format): accepts JDBC (the JSON contract the route emits); throws an ErrorReport(UNSUPPORTED_OPERATION, ANALYZING) with a suggestion for csv/raw/viz.
  • Wire the guard into both analytics entry points:
    • SQLPlugin#createSqlAnalyticsRouter (SQL _sql route)
    • TransportPPLQueryAction#doExecute (PPL _ppl route)
  • The thrown ErrorReport flows through the existing REST error handling (RestSqlAction/RestPPLQueryAction), which classifies its IllegalArgumentException cause as a client error → 400.

Related Issues

N/A

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…a 4xx

The analytics-engine (Calcite/DataFusion) route formats every response with
SimpleJsonResponseFormatter and does not implement the alternate response
formats (csv/raw/viz) supported by the classic SQL/PPL engines. A request such
as `format=csv` against an analytics index was silently answered with JSON:
the client asked for one content type and received another, with no signal that
the parameter was dropped.

This adds an up-front guard on the analytics route that rejects an unsupported
output format with a structured ErrorReport coded UNSUPPORTED_OPERATION, so the
client gets a clean 4xx with an actionable message instead of silent JSON.
JSON/JDBC (the default) is unaffected.

Changes:
  - New AnalyticsEngineFormatSupport.validateFormat(Format): accepts JDBC (the
    JSON contract the route emits); throws an ErrorReport(UNSUPPORTED_OPERATION,
    ANALYZING) with a suggestion for csv/raw/viz.
  - Wire the guard into both analytics entry points:
      * SQLPlugin#createSqlAnalyticsRouter (SQL `_sql` route)
      * TransportPPLQueryAction#doExecute (PPL `_ppl` route)
    The thrown ErrorReport flows through the existing REST error handling
    (RestSqlAction/RestPPLQueryAction), which classifies its IllegalArgumentException
    cause as a client error -> 400.

Tests:
  - AnalyticsEngineFormatSupportTest: JDBC accepted; csv/raw/viz rejected with
    UNSUPPORTED_OPERATION, a message naming the format + "analytics engine",
    and a suggestion.
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
@RyanL1997 RyanL1997 added analytic-engine error-experience Issues related to how we handle failure cases in the plugin. enhancement New feature or request labels Jun 19, 2026
@RyanL1997 RyanL1997 changed the title Reject unsupported output formats on the analytics-engine route with a 4xx [Enhancement] Reject unsupported output formats on the analytics-engine route with a 4xx Jun 19, 2026
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
@dai-chen

Copy link
Copy Markdown
Collaborator

As follow-up, later we can consider either move this into unifiedQueryHandler.execute or do language-specific validation here. Thanks!

@RyanL1997 RyanL1997 merged commit f6b6baa into opensearch-project:main Jun 19, 2026
28 of 32 checks passed
@RyanL1997 RyanL1997 deleted the fix/ae-reject-unsupported-format branch June 19, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analytic-engine enhancement New feature or request error-experience Issues related to how we handle failure cases in the plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants