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

zilla:correlation-id header sort #508

Closed
dudo opened this issue Oct 13, 2023 · 2 comments
Closed

zilla:correlation-id header sort #508

dudo opened this issue Oct 13, 2023 · 2 comments
Assignees

Comments

@dudo
Copy link

dudo commented Oct 13, 2023

Is your feature request related to a problem? Please describe.
Currently, correlationId is calculated on the headers as is. I experienced some curl commands mixing up the header order, and getting different ids

Screenshot 2023-10-12 at 13 59 53

Describe the solution you'd like
Sort the headers before calculating the digest.

Describe alternatives you've considered
Not sure if there's a more clever java-y solution that can inspect a hash/dictionary and give the same value regardless of order.

Additional context
I believe the code that calculated the correlationId is here? I'm happy to work on a PR.

@attilakreiner
Copy link
Contributor

@dudo, thx for submitting this issue. I couldn't replicate this behaviour with curl. Can you post some specific reproduction steps, the actual curl commands, that resulted in the mixed-up header order?

@attilakreiner
Copy link
Contributor

attilakreiner commented Nov 30, 2023

After some more deep dive, it turns out that the header order wasn't the problem in the first place.

The problem was caused by the missing idempotency key as the curl command was issued this way:
curl -X POST http://localhost:9090/command -H "idempotencyKey: hello"
as opposed to
curl -X POST http://localhost:9090/command -H "Idempotency-Key: hello"
(Mind the missing dash; the upper/lower case doesn't actually make a difference.)

In the first case, the idempotency key was missing, so zilla generated a random one, that's why the correlationId was a different value on every invocation of the command. In the second case, when using the correct command, the resulting correlationId is consistently the same for multiple invocations of the same command. The ordering of the headers (and other input pieces for the hash) is actually deterministic.

FYI: All header names are converted to lowercase, because we internally follow http2 header naming conventions in our abstractions, even for http/1.1.

For more information pls chk this slack thread:
https://aklivitycommunity.slack.com/archives/C027SEH2KRC/p1697144918651569

@jfallows jfallows closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants