Skip to content

Demonstrate HTTP QUERY for the read-only SQL interface - #5058

Draft
epugh wants to merge 6 commits into
apache:mainfrom
epugh:sql-query-demo
Draft

epugh wants to merge 6 commits into
apache:mainfrom
epugh:sql-query-demo

Conversation

@epugh

@epugh epugh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Description

Demonstrates sending read-only SQL requests using HTTP QUERY without changes to Jetty. The Admin UI SQL screen offers GET, POST, and QUERY, with POST as the default. GET sends stmt in the URL; POST and QUERY send it in a form-encoded body.

Solution

Adds QUERY to Solr's HTTP method handling and the Jetty-backed SolrJ client, defines a JAX-RS @QUERY annotation, and adds a test-only V2 Jersey endpoint to prove JSON body handling over HTTP/1.1 and HTTP/2. Developer documentation describes when QUERY is appropriate.

This is an experiment, not complete public API support. Other SolrJ transports, distributed forwarding, authorization policies, OpenAPI generation, and QUERY caching still need validation.

Dependency: this branch is based on SOLR-16640. Its diff against main currently includes the SQL screen's missing-module error handling, clickable documentation link, and techproducts SQL-module enablement. The isolated QUERY demonstration is commit 0b81777fef9; those prerequisite changes can be removed from this PR's diff after they land separately.

Implemented with Codex assistance.

Tests

  • Seven headless Chrome SQL screen tests passed, covering actual GET/POST/QUERY verbs, body versus URL parameters, 20 KB SQL statements, and the documentation link.
  • Twelve core tests passed: HttpQueryIntegrationTest and SolrRequestParserTest.
  • ./gradlew tidy and ./gradlew check -x test passed.
  • The focused SOLR-16640 base was separately validated with its three SQL browser tests and check -x test.

Checklist

  • Added tests for the demonstrated behavior.
  • Added developer documentation.
  • Assigned a dedicated JIRA issue to the QUERY experiment.
  • Ready for production use or merge.

epugh added 6 commits October 7, 2026 10:30
doQuery() assumed every response was a SQL result-set and crashed with
an uncaught TypeError ("Cannot read properties of undefined (reading
'docs')") whenever it wasn't - e.g. when the sql module/handler isn't
installed, which returns a 404 JSON body with no "result-set" key. The
UI was then left showing a blank grid with no explanation.

Wrapped the response handling (shared between the success and error
callbacks, since app.js's doNotIntercept interceptor quirk routes most
failures through the success callback too - same root cause as
SOLR-9759) to fall back to showing the raw message via the existing
sqlError display instead of crashing.
There's no v2 API to proactively check whether the sql module/handler
is actually loadable (every core nominally registers /sql lazily
regardless of whether the module jar is present, so only a real
request reveals it's missing) - confirmed by checking for a modules-
info or eager-plugin-load API, finding none.

So instead: detect the specific ClassNotFoundException-for-SQLHandler
shape in the error response and show "the sql module doesn't appear
to be enabled" instead of the raw stack trace. Verified against a real
build without the sql module (dev-slim) that this is the exact error
shape produced.

Also hoisted showResult() out of doQuery() so it's available as soon
as the controller loads rather than only after the first query attempt
- this also makes it directly testable (new
testSqlModuleNotEnabledShowsFriendlyMessage calls it via the Angular
scope with the captured error shape, since the webapp test classpath
always has the sql module and can't reproduce the missing-module case
through a real request).
@epugh
epugh requested review from dsmiley and gus-asf October 7, 2026 19:13
@epugh

epugh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

I made a video of the QUERY verb in action! https://share.descript.com/view/ONLMnrXdlYs

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant