You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/03/08 14:58:47 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5009: api: Warn if query parameters have multiple values

DaanHoogland commented on a change in pull request #5009:
URL: https://github.com/apache/cloudstack/pull/5009#discussion_r821747082



##########
File path: server/src/main/java/com/cloud/api/ApiServer.java
##########
@@ -464,7 +464,11 @@ public void handle(final HttpRequest request, final HttpResponse response, final
                         responseType = param.getValue();
                         continue;
                     }
-                    parameterMap.put(param.getName(), new String[]{param.getValue()});
+                    if(parameterMap.putIfAbsent(param.getName(), new String[]{param.getValue()}) != null) {
+                        String message = String.format("Query parameter '%s' has multiple values [%s, %s]. Only the last value will be respected." +
+                            "It is advised to pass only a single parameter", param.getName(), param.getValue(), parameterMap.get(param.getName()));
+                        s_logger.warn(message);

Review comment:
       is there a joint `ApiServer`/`ApiServlet` Utility to put this warning message in, instead of copying the exact same text?
   Alternatively can we change the text to indicate where/why we object to the duplicate parameter?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org