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

Fix #4009: reorder the registration of routes #4017

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

gsnedders
Copy link
Member

Per the mux docs, "Routes are tested in the order they were added to the router. If two routes match, the first one wins."

This means that checks.RegisterRoutes() needs to be called after everything else defining a route in /api/checks/ as it otherwise matches every path under /api/checks/.

Fixes #4009; see also #4010. @past said in the latter said:

Oh, that would probably work, too.

Turns out it doesn't and I don't know why.

In way of minimal testing:

gsnedders@gsnedders-milk wpt.fyi % curl -v -Li --data-urlencode 'run_id=10906214822' --data-urlencode 'owner=web-platform-tests' --data-urlencode 'repo=wpt' --data-urlencode 'artifact_name=safari-technology-preview-results-%2A' 'http://localhost:8080/api/checks/github-actions/'
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying [::1]:8080...
* connect to ::1 port 8080 from ::1 port 52803 failed: Connection refused
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080
> POST /api/checks/github-actions/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Length: 106
> Content-Type: application/x-www-form-urlencoded
> 
} [106 bytes data]
* upload completely sent off: 106 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain; charset=utf-8
< Strict-Transport-Security: max-age=31536000; preload
< X-Content-Type-Options: nosniff
< Date: Tue, 24 Sep 2024 21:24:46 GMT
< Content-Length: 105
< 
{ [105 bytes data]

100   211  100   105  100   106    404    408 --:--:-- --:--:-- --:--:--   814
* Connection #0 to host localhost left intact
HTTP/1.1 500 Internal Server Error
Content-Type: text/plain; charset=utf-8
Strict-Transport-Security: max-age=31536000; preload
X-Content-Type-Options: nosniff
Date: Tue, 24 Sep 2024 21:24:46 GMT
Content-Length: 105

GET https://api.github.com/repos/web-platform-tests/wpt/actions/runs/10906214822: 401 Bad credentials []

Per the mux docs, "Routes are tested in the order they were added to
the router. If two routes match, the first one wins."

This means that `checks.RegisterRoutes()` needs to be called after
everything else defining a route in /api/checks/ as it otherwise
matches every path under /api/checks/.
@KyleJu KyleJu requested a review from past September 24, 2024 21:50
Copy link
Member

@past past left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying your curl example pointed out the problem with my testing last night: I was testing with a browser tab to make the request, which of course was making a GET call.

That's what I get for coding late in the evening after a day full of meetings :-)

@past past merged commit cd7b83f into web-platform-tests:main Sep 25, 2024
12 checks passed
@gsnedders gsnedders deleted the reorder-routes branch September 25, 2024 06:27
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 this pull request may close these issues.

ghactions.notifyHandler doesn't get called for requests to /api/checks/github-actions
2 participants