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

Webhooks post X-Github-* should be X-GitHub-* #3304

Closed
5 tasks
robe2 opened this issue Jan 5, 2018 · 11 comments · Fixed by #3429
Closed
5 tasks

Webhooks post X-Github-* should be X-GitHub-* #3304

robe2 opened this issue Jan 5, 2018 · 11 comments · Fixed by #3429
Labels
Milestone

Comments

@robe2
Copy link

robe2 commented Jan 5, 2018

  • Gitea version (or commit ref): 1.3.2+3-g88c363f9
  • Git version: 1.7
  • Operating system: Debian
  • Database (use [x]):
    • [x ] PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • [x ] Not relevant
  • Log gist:

Description

I setup a Jenkins generic web hook with hopes to handle both gitea and github pull requests and for the most part gitea can impersonate a github webhook.
However my webhook was looking for filter:

X-GitHub-Event

note the uppercase H this is because GitHub's pull requests have a header like this:

X-GitHub-Delivery: 23f8ed5c-f240-11e7-84b3-acee9f3589e5
X-GitHub-Event: pull_request

While Gitea outputs like this:

X-Github-Delivery: 5c2938d1-ec68-458d-af63-cc29919ffbbf
X-Github-Event: pull_request

The h should be upper-cased to be consistent with how GitHub posts their web hooks
...

Screenshots

@robe2
Copy link
Author

robe2 commented Jan 5, 2018

I'll try to provide a patch for this once I'm setup unless this casing was intentional for some reason. Still studying gitea code-base.

@strk
Copy link
Member

strk commented Jan 5, 2018

The code seems to have right casing:
https://github.com/go-gitea/gitea/blob/v1.3.2/models/webhook.go#L581-L586
maybe something re-cases it ?

@strk
Copy link
Member

strk commented Jan 5, 2018

From go doc http.Request:

        // HTTP defines that header names are case-insensitive. The
        // request parser implements this by using CanonicalHeaderKey,
        // making the first character and any characters following a
        // hyphen uppercase and the rest lowercase.

@robe2
Copy link
Author

robe2 commented Jan 5, 2018

hmm I wonder how many tools abide by that rule. Since it's coming thru as a key-value store the casing is preserved when I query it and two terms have different keys. I assume any language that are case sensitive might have similar issue.

Though if it's meant to be case sensitive anyway why does the http lib bother changing the case of input from what programmer specified? Seems like a needless exercise that just causes confusion.

@lafriks
Copy link
Member

lafriks commented Jan 5, 2018

I think most the languages that have standard lib for header parsing have keys case insensitive

@robe2
Copy link
Author

robe2 commented Jan 5, 2018

Okay then it's probably not worth the bother fixing given it's so deeply embedded.

@robe2 robe2 closed this as completed Jan 5, 2018
@robe2
Copy link
Author

robe2 commented Jan 5, 2018

Just closed this before I read this related ticket

golang/go#5022

Would it be possible to use header key directly just for this GitHub thing that really should match what github is posting in their webhook?

If that's agreeable I'll be happy to reopen this and test it out.

@strk
Copy link
Member

strk commented Jan 5, 2018 via email

@robe2 robe2 reopened this Jan 5, 2018
@bkcsoft
Copy link
Member

bkcsoft commented Jan 8, 2018

Headers are case insensitive, Jenkins is broken and should be fixed 🙄

4.2 => https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html

@lunny lunny added the type/bug label Jan 9, 2018
@strk
Copy link
Member

strk commented Jan 9, 2018

beside Jenkins being or not broken, this issue is about the GitHub compatibility header being NOT THE SAME as the one sent by GitHub. If we want to comply let's comply

@thehowl
Copy link
Contributor

thehowl commented Jan 9, 2018

I agree on the change. Though it might cause some breakage, users which depend on the casing have an underlying problem in their http lib, which is that of headers being case sensitive when they should be insensitive. On the plus side, we get API that is compatible with github.

@lafriks lafriks added this to the 1.4.0 milestone Jan 30, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants