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

GET webhooks/:webhookId/:webhookToken/messages/:msgId always returns 404 #19

Open
Larsundso opened this issue Aug 31, 2024 · 3 comments · May be fixed by #21
Open

GET webhooks/:webhookId/:webhookToken/messages/:msgId always returns 404 #19

Larsundso opened this issue Aug 31, 2024 · 3 comments · May be fixed by #21

Comments

@Larsundso
Copy link

Larsundso commented Aug 31, 2024

How to reproduce:

Possible prerequisites

Every time i restarted the docker image it would work for 5-10 seconds before returning 404 again
The error description would be "No Description"
I encountered this only after releasing a Feature that would utilize several hundred webhooks sending several thousand requests per minute combined

@Larsundso
Copy link
Author

I'm not sure what other webhook endpoints are affected, but DELETE webhook message is too

@Larsundso
Copy link
Author

Larsundso commented Aug 31, 2024

Fixed by restarting the docker container
Edited issue

@Zoddo
Copy link

Zoddo commented Sep 1, 2024

@Larsundso I think you can reopen the issue because you found a bug.

I can repro reliably by trying to get a message that don't/no longer exists.

Repro steps:

  1. Post a message using a valid webhook: curl -i -X POST -H 'Content-Type: application/json' http://nirn-proxy.prod.svc.cluster.local/api/webhooks/:id/:token?wait=true -d '{"content":"test"}'
  2. Get the message, it should returns a 200: curl -i http://nirn-proxy.prod.svc.cluster.local/api/webhooks/:id/:token/messages/:id
  3. Repeats step 2 with an invalid ID (do +1 in the message ID). You get a {"message": "404: Not Found", "code": 0} as expected.
  4. Repeat step 2 again with the valid message ID. You now get a fake 404 "Unknown webhook" originating from nirn (as it can be seen with the missing CF's headers in the response).

The issue likely lies here:

nirn-proxy/lib/queue.go

Lines 351 to 358 in 23fc2e7

if resp.StatusCode == 404 && strings.HasPrefix(path, "/webhooks/") && !isInteraction(item.Req.URL.String()) {
logger.WithFields(logrus.Fields{
"bucket": path,
"route": item.Req.URL.String(),
"method": item.Req.Method,
}).Info("Setting fail fast 404 for webhook")
ret404 = true
}

It should additionally check if the body code is 10015 (Unknown webhook).

I looked to make a PR but I'm not sure how to parse the body and I'm not a go dev :(

@Larsundso Larsundso reopened this Sep 1, 2024
@bsian03 bsian03 linked a pull request Nov 8, 2024 that will close this issue
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.

2 participants