Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Query Parameters on an HTTP Sender Connector are not sent in order #6276

Open
joshmc82 opened this issue Aug 7, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@joshmc82
Copy link

joshmc82 commented Aug 7, 2024

Describe the bug
When using the Query Parameters section of the HTTP Sender connector, the parameters can be sent out of order. This breaks some APIs that require a specific order for parameters. In my particular use case, the API I'm trying to communicate with requires me to use HMAC to hash the URI. If that hash doesn't match exactly to the full URI actually sent, it will reject the request.

To Reproduce

  1. Setup an echo server somewhere (i.e. npx http-echo-server)
  2. Create a channel with an http sender connector to send to your echo server URL
  3. Add multiple query parameters using the table (i.e. "start_date", "end_date", "app_id"). Use any values

Steps to reproduce the behavior:

  1. Send a message through your channel
  2. Observe the output in the console for your echo server
  3. See that the parameters are not in the order you set them

Expected behavior
The destination connector should preserve the order of the parameters as entered.

Actual behavior
The parameters are not in the order entered in the UI.

Environment (please complete the following information):

  • OS: Rocky Linux 8, CentOS 7
  • Java Distribution/Version OpenJDK. 17
  • Connect Version 3.12-4.5

Workaround(s)
I have to manually build my URL string, store it on the channel map and use that as my http URL on the connector, not using any query parameters on the UI.

Additional context
It doesn't matter if you tell the connector to use the table or use a map variable. The behavior is the same.
I even tried a LinkedHashMap to attempt to force the order.

The code appears to be creating a new map from the existing map here:

public static Map<String, List<String>> getTableMap(String mapVariable, MessageMaps messageMaps, ConnectorMessage connectorMessage) {

Example Code
Here is an example of where I tried to use a LinkedHashMap to force the order:

var LinkedHashMap = Packages.java.util.LinkedHashMap;
// Create a new LinkedHashMap instance
var orderedMap = new LinkedHashMap();
orderedMap.put('app_id', 'uuid----------');
orderedMap.put('phi_level', 'high');
orderedMap.put('start_date', '2024-08-01');
orderedMap.put('end_date', '2024-08-31');
orderedMap.put('demographics_detail', 'high');
orderedMap.put('patient_status_detail', 'high');

And the corresponding output from my echo server:
/?end_date=2024-08-31&phi_level=high&patient_status_detail=high&demographics_detail=high&app_id=uuid----------&start_date=2024-08-01 HTTP/1.1

@joshmc82 joshmc82 added the bug Something isn't working label Aug 7, 2024
rogin added a commit to rogin/connect that referenced this issue Sep 10, 2024
Shurazi added a commit to Shurazi/connect that referenced this issue Sep 12, 2024
Shurazi pushed a commit to Shurazi/connect that referenced this issue Sep 14, 2024
(cherry picked from commit 30d2760)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant