This is an automated email from the ASF dual-hosted git repository. rnewson pushed a commit to branch dropwizard-5 in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit b8bfe77ee45a63b7afb56f696264e48059694c82 Author: Robert Newson <[email protected]> AuthorDate: Sun Mar 29 16:54:37 2026 +0100 move name/path/docid to query params Avoid the 400 Ambiguous Path Separator errors raised by the escaped / (%2F) in each. --- .../couchdb/nouveau/resources/IndexResource.java | 28 +++++++++++----------- src/nouveau/src/nouveau_api.erl | 12 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java index 182152a5d..87f7a9c59 100644 --- a/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java +++ b/extra/nouveau/src/main/java/org/apache/couchdb/nouveau/resources/IndexResource.java @@ -24,8 +24,8 @@ import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response.Status; @@ -43,7 +43,7 @@ import org.apache.couchdb.nouveau.api.SearchRequest; import org.apache.couchdb.nouveau.api.SearchResults; import org.apache.couchdb.nouveau.core.IndexManager; -@Path("/index/{name}") +@Path("/index") @Metered @ResponseMetered @ExceptionMetered(cause = IOException.class) @@ -58,7 +58,7 @@ public final class IndexResource { } @PUT - public Ok createIndex(@PathParam("name") String name, @NotNull @Valid IndexDefinition indexDefinition) + public Ok createIndex(@QueryParam("name") String name, @NotNull @Valid IndexDefinition indexDefinition) throws IOException { if (!indexDefinition.isLatestVersion()) { throw new WebApplicationException( @@ -71,10 +71,10 @@ public final class IndexResource { @Deprecated(since = "3.5.2", forRemoval = true) @DELETE - @Path("/doc/{docId}") + @Path("/doc") public Ok deleteDoc( - @PathParam("name") String name, - @PathParam("docId") String docId, + @QueryParam("name") String name, + @QueryParam("doc_id") String docId, @NotNull @Valid DocumentDeleteRequest request) throws Exception { return indexManager.with(name, (index) -> { @@ -84,20 +84,20 @@ public final class IndexResource { } @DELETE - public Ok deletePath(@PathParam("name") String path, @Valid final List<String> exclusions) throws IOException { + public Ok deletePath(@QueryParam("name") String path, @Valid final List<String> exclusions) throws IOException { indexManager.deleteAll(path, exclusions); return Ok.INSTANCE; } @GET - public IndexInfoResponse getIndexInfo(@PathParam("name") String name) throws Exception { + public IndexInfoResponse getIndexInfo(@QueryParam("name") String name) throws Exception { return indexManager.with(name, (index) -> { return index.info(); }); } @POST - public Ok setIndexInfo(@PathParam("name") String name, @NotNull @Valid IndexInfoRequest request) throws Exception { + public Ok setIndexInfo(@QueryParam("name") String name, @NotNull @Valid IndexInfoRequest request) throws Exception { return indexManager.with(name, (index) -> { var shouldCommit = false; if (request.matchUpdateSeq().isPresent() && request.updateSeq().isPresent()) { @@ -120,7 +120,7 @@ public final class IndexResource { @POST @Path("/search") - public SearchResults searchIndex(@PathParam("name") String name, @NotNull @Valid SearchRequest request) + public SearchResults searchIndex(@QueryParam("name") String name, @NotNull @Valid SearchRequest request) throws Exception { return indexManager.with(name, (index) -> { return index.search(request); @@ -129,10 +129,10 @@ public final class IndexResource { @Deprecated(since = "3.5.2", forRemoval = true) @PUT - @Path("/doc/{docId}") + @Path("/doc") public Ok updateDoc( - @PathParam("name") String name, - @PathParam("docId") String docId, + @QueryParam("name") String name, + @QueryParam("doc_id") String docId, @NotNull @Valid DocumentUpdateRequest request) throws Exception { return indexManager.with(name, (index) -> { @@ -143,7 +143,7 @@ public final class IndexResource { @POST @Path("/update") - public Ok update(@PathParam("name") String name, @NotNull @Valid BulkUpdateRequest request) throws Exception { + public Ok update(@QueryParam("name") String name, @NotNull @Valid BulkUpdateRequest request) throws Exception { return indexManager.with(name, (index) -> { for (var update : request.updates()) { if (update.update() instanceof DocumentUpdateRequest) { diff --git a/src/nouveau/src/nouveau_api.erl b/src/nouveau/src/nouveau_api.erl index 5ae7c4ce4..790108ed1 100644 --- a/src/nouveau/src/nouveau_api.erl +++ b/src/nouveau/src/nouveau_api.erl @@ -318,23 +318,23 @@ supported_lucene_versions() -> %% private functions index_path(Path) when is_binary(Path) -> - [<<"/index/">>, couch_util:url_encode(Path)]; + [<<"/index?name=">>, couch_util:url_encode(Path)]; index_path(#index{} = Index) -> - [<<"/index/">>, couch_util:url_encode(nouveau_util:index_name(Index))]. + [<<"/index?name=">>, couch_util:url_encode(nouveau_util:index_name(Index))]. doc_path(#index{} = Index, DocId) -> [ - <<"/index/">>, + <<"/index?name=">>, couch_util:url_encode(nouveau_util:index_name(Index)), - <<"/doc/">>, + <<"&doc_id=">>, couch_util:url_encode(DocId) ]. search_path(#index{} = Index) -> - [index_path(Index), <<"/search">>]. + [<<"/index/search?name=">>, couch_util:url_encode(nouveau_util:index_name(Index))]. update_path(#index{} = Index) -> - [index_path(Index), <<"/update">>]. + [<<"/index/update?name=">>, couch_util:url_encode(nouveau_util:index_name(Index))]. jaxrs_error(400, Body) -> {bad_request, message(Body)};
