api: Warn if query parameters have multiple values#5009
api: Warn if query parameters have multiple values#5009nvazquez merged 4 commits intoapache:mainfrom
Conversation
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖️ centos7 ✖️ centos8 ✖️ debian. SL-JID 557 |
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✖️ centos7 ✖️ centos8 ✖️ debian. SL-JID 558 |
| String message = String.format("Query parameter '%s' has multiple values", param.getName()); | ||
| s_logger.error(message); | ||
| throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, message); |
There was a problem hiding this comment.
this is a repeating bit (also happening in ApuServlet) maybe we can move (parts of) it to a common utility?
|
Packaging result: ✔️ centos7 ✖️ centos8 ✔️ debian. SL-JID 564 |
|
@blueorangutan test |
|
@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-646)
|
|
@davidjumani although you link the issue, could you improve the description of this PR with more context? |
|
@davidjumani I'm not sure if it may cause any regression, since we're tight for a RC this or early next week, I'm moving the milestone. |
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 2713 |
|
@blueorangutan test |
|
@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3433)
|
|
this might cause backwards compatibility issue. I suggest to hold on |
what kind of issues, @weizhouapache ? |
@DaanHoogland |
|
@weizhouapache I've updated it to a warning and to not throw an error |
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 2762 |
|
@blueorangutan test |
|
@davidjumani a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
@blueorangutan test |
|
@nvazquez a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3507)
|
|
@blueorangutan package |
|
@davidjumani a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian ✔️ suse15. SL-JID 2791 |
|
Smoke tests won't be needed as they passed the previous time and only cosmetic changes were made |
|
@davidjumani I've manually tested and looks good, I have some minor improvement request: If passing multiples values for a parameter we use the last, however if I attempt the same on cmk, cmk only passes the first parameter. Can we change the value used to be the first instead of the last so they are consistent? |
| 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); |
There was a problem hiding this 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 a cmk specific implementation. If an API is called via a browser or tool which simply creates / forwards the requests the last value is respected |
Description
Fixes #5007
When duplicate query parameters are passed with the same key but different values, ACS parses only the last occurrence.
Eg: keyword=rick&keyword=basic
It returns values matching basic
This PR fixes it so it throws an error when multiple values for the same key is sent
Types of changes
Bug Severity
How Has This Been Tested?