Skip to content

Migrate Schema Designer to JAX-RS Apis. Fix some bugs.#4203

Open
epugh wants to merge 12 commits intoapache:mainfrom
epugh:copilot/migrate-schemadesignerapi-to-v2-annotations
Open

Migrate Schema Designer to JAX-RS Apis. Fix some bugs.#4203
epugh wants to merge 12 commits intoapache:mainfrom
epugh:copilot/migrate-schemadesignerapi-to-v2-annotations

Conversation

@epugh
Copy link
Contributor

@epugh epugh commented Mar 10, 2026

Summary

Migrate the SchemaDesigner to JAX-RS. Fixed a bug in the analyze feature that wasn't working in main.

Changes

JAX-RS adoption, and code review. Had to change up the routes in the JavaScript to be more restful for generating the configset download.

The runtime behaviour is unchanged.

Copilot AI and others added 8 commits February 22, 2026 14:50
Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
…mments

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
…y docs guard)

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
…ader, sanitize filename

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
…/docs map for JS rendering

Co-authored-by: epugh <22395+epugh@users.noreply.github.com>
@epugh epugh requested a review from Copilot March 10, 2026 09:50
@epugh epugh changed the title Fix unchecked cast warning in DefaultSampleDocumentsLoader Migrate Schema Designer to Ja Mar 10, 2026
@epugh epugh changed the title Migrate Schema Designer to Ja Migrate Schema Designer to JAX-RS Apis. Fix some bugs. Mar 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Schema Designer v2 API implementation to a Jersey-based resource + OpenAPI-defined interface, updates the admin UI download URL accordingly, and includes a small improvement to JSON-lines parsing to avoid unchecked-cast warnings.

Changes:

  • Migrate SchemaDesignerAPI from the legacy @EndPoint style to a JerseyResource implementing a new SchemaDesignerApi interface, and update tests to call the new method signatures.
  • Adjust the Schema Designer UI download endpoint URL to the new /api/schema-designer/download?configSet=... form.
  • Narrow unchecked-cast suppression in DefaultSampleDocumentsLoader via a helper method using instanceof Map<?, ?>.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
solr/webapp/web/js/angular/controllers/schema-designer.js Updates Schema Designer download URL to new endpoint shape.
solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java Reworks tests to call new Jersey-style API methods and response handling.
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerSettings.java Changes settings class visibility to public.
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConstants.java Removes unused constants related to old request-param handling.
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java Minor cleanup/modernization and removal of unused helper logic.
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java Major migration to JerseyResource + SchemaDesignerApi, plus download/query response changes.
solr/core/src/java/org/apache/solr/handler/designer/SampleDocuments.java Uses Stream.toList() instead of Collectors.toList().
solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java Adjusts field-prop guessing API/signature usage.
solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java Introduces parseStringToJson() helper and narrows unchecked-cast suppression.
solr/core/src/java/org/apache/solr/core/CoreContainer.java Registers Schema Designer as a Jersey resource class.
solr/api/src/java/org/apache/solr/client/api/endpoint/SchemaDesignerApi.java Adds new OpenAPI/JAX-RS interface defining Schema Designer endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 1528 to 1531
var xhr = new XMLHttpRequest();
xhr.open("GET", "/api/schema-designer/download/"+fileName+"?wt=raw&configSet="+$scope.currentSchema, true);
xhr.open("GET", "/api/schema-designer/download?configSet="+$scope.currentSchema, true);
xhr.setRequestHeader('Authorization', sessionStorage.getItem("auth.header"));
xhr.responseType = 'blob';
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The download request no longer includes a wt param or an explicit Accept header. With the current MediaTypeOverridingFilter, requests with Accept: */* (common for browser navigations) get their Content-Type forcibly set to application/json, which undermines this endpoint’s application/zip response. Consider either re-adding a wt query param (as before) to bypass the default override, or set Accept: application/zip on the XHR branch and keep a wt param on the non-auth location.href branch.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm.. it's working just fine?

Comment on lines 822 to 826
if (errorsDuringIndexing != null) {
Map<String, Object> response = new HashMap<>();
rsp.setException(
new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"Failed to re-index sample documents after schema updated."));
response.put(ERROR_DETAILS, errorsDuringIndexing);
rsp.getValues().addAll(response);
return;
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"Failed to re-index sample documents after schema updated.");
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

query() used to return an error response containing errorDetails when re-indexing failed, which the Schema Designer UI surfaces (see its errorHandler). This new implementation throws a SolrException without attaching errorDetails, so clients will lose the per-doc failure details. Consider instantiating a FlexibleSolrJerseyResponse early and setting an errorDetails top-level property before throwing, or otherwise preserve the prior error payload structure.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I dug in and found some bugs and fixed them in how we surface errors.
image

Comment on lines +1349 to 1354
protected void requireSchemaVersion(Integer schemaVersion) {
if (schemaVersion == null) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
SCHEMA_VERSION_PARAM + " is a required parameter for the " + req.getPath() + " endpoint");
SolrException.ErrorCode.BAD_REQUEST, SCHEMA_VERSION_PARAM + " is a required parameter!");
}
return schemaVersion;
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

requireSchemaVersion() now only rejects null, but previously the API treated -1 as “missing” (since getInt(..., -1) was used) and rejected it. As written, a client can pass schemaVersion=-1 and bypass this validation; it would be safer to also reject negative values to keep the same contract.

Copilot uses AI. Check for mistakes.
@epugh epugh requested review from dsmiley and janhoy March 10, 2026 10:43
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.

3 participants