Skip to content

Alfresco REST API, NodesApi.listNodeChildren not processing include parameter correctly (missing @CollectionFormat(feign.CollectionFormat.CSV)) #3034

Open
@Verdoso

Description

Hi there,
I'm implement a service that accesses Alfresco 23.1.0 using alfresco-java-rest-api-spring-boot-starter:5.0.0. We also have the Alfresco Explorer, so I can verify the operations and check unexpected results. Now, to the point:

When accessing the endpoint "#/nodes/listNodeChildren", one can specify the fields to be included in the response using the include parameter, that allows you to specify multiple fields. Using the explorer, and specifying the fields (properties, aspectNames, and path) the request sent looks something like this:
.../children?skipCount=0&maxItems=100&include=properties,aspectNames,path

In code, one has to use the NodesApi class that has the corresponding nodesApi.listNodeChildren that accepts a List in the include parameter. But, if you specify the parameter with a list, as expected:
List<String> include = List.of("path", "aspectNames", "properties");
and then check the resulting HTTP request being sent, you will see that it sends a request like this:
.../children?skipCount=0&maxItems=100&include=properties&include=aspectNames&include=path
treating the parameter as multiple. The server does not process that request correctly and just takes into account the last value of the parameter, so you don't see, in this example, the aspectNames or the properties of the resulting nodes.

If, on the other hand, you declare the parameter as a List with one value where the fields are concatenated:
List<String> include = List.of(String.join(",", new String[] {"path", "aspectNames", "properties"}));
you can finally see all the requested fields included.

This problem is caused by Feign and the way the List parameters are handled (see for example this S.O. question: https://stackoverflow.com/questions/41744542/spring-cloud-feign-client-requestparam-with-list-parameter-creates-a-wrong-requ) and it seems that the solution would be to simply specify that the parameters have to be passed as CSV using @CollectionFormat(feign.CollectionFormat.CSV) in the method in the interface.

Cheers!
D.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions