Skip to content

SOLR-16640: Admin UI's SQL screen shows an error instead of crashing - #5057

Open
epugh wants to merge 6 commits into
apache:mainfrom
epugh:SOLR-16640
Open

epugh wants to merge 6 commits into
apache:mainfrom
epugh:SOLR-16640

Conversation

@epugh

@epugh epugh commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-16640

Description

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.

Solution

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.

Tests

manual

happy path:
image

sad path:
image

epugh added 2 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).
@github-actions github-actions Bot added documentation Improvements or additions to documentation client:solrj cat:cli cat:api labels Oct 7, 2026
@epugh
epugh requested a review from janhoy October 7, 2026 19:07
@github-actions github-actions Bot removed documentation Improvements or additions to documentation client:solrj cat:api labels Oct 7, 2026
Comment thread solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
@epugh epugh added this to the 10.x milestone Oct 7, 2026

@janhoy janhoy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants