GoogleCloudPlatform / cloud-run-button

Let anyone deploy your GitHub repos to Google Cloud Run with a single click
https://cloud.run
Apache License 2.0
526 stars 91 forks source link

Error when clicking button: failed to parse Referer header: failed to extract URL components: url is not sufficient to infer the repository name #162

Closed steren closed 3 years ago

steren commented 4 years ago

I am on https://github.com/steren/cloud-run-node-14/blob/master/README.md or on https://github.com/steren/cloud-run-node-14

I click he Cloud Run button.

I get:

"failed to parse Referer header: failed to extract URL components: url is not sufficient to infer the repository name"

steren commented 4 years ago

My markup was [![Run on Google Cloud](https://deploy.cloud.run/button.svg)](https://deploy.cloud.run)

I have recently renamed this repo.

steren commented 4 years ago

I am on Chrome Version 81.0.4044.94 (Official Build) beta (64-bit)

steren commented 4 years ago

When I open DevTools's networking tab, I see in the request headers:

referer: https://github.com/

steren commented 4 years ago

Here is the markup I see that GitHub is generating for my button:

<a href="https://deploy.cloud.run" rel="nofollow"><img src="https://camo.githubusercontent.com/7f69e1c95299d52a177b0fa5ad6b2c3d883b33e1/68747470733a2f2f6465706c6f792e636c6f75642e72756e2f627574746f6e2e737667" alt="Run on Google Cloud" data-canonical-src="https://deploy.cloud.run/button.svg" style="max-width:100%;"></a>
ahmetb commented 4 years ago

We tried to debug this, so far no luck. Chrome 80 vs 81 doesn't seem to be the issue. Encountered https://www.chromestatus.com/feature/6251880185331712 which seems relevant, but about Chrome 84 however I'm not observing the behavior.

ahmetb commented 4 years ago

Actually right now this might not be a problem, but it will certainly be a problem with Chrome 84. The link above says:

When no such policy is specified, Chrome will now use strict-origin-when-cross-origin as the default policy, instead of no-referrer-when-downgrade. On

no-referrer-when-downgrade was allowing us to get the full URL (since https://deploy.cloud.run is an HTTPS page).

With strict-origin-when-cross-origin we will only get Referer: https://github.com/ unless we can get GitHub to specify an explicit referer policy. I think we need to start pulling some strings until Chrome 84 comes around the corner.

steren commented 4 years ago

Ok, so we diagnosed this, it was due to a Chrome flag: chrome://flags/#reduced-referrer-granularity

It was set to "Default" for me, but when I disabled it, I can use the Cloud Run button again. It's likely an org policy to enable this flag on our Pixelbooks.

jamesward commented 4 years ago

Nice work figuring this out! So, should we start recommending people hard-code the git repo in the button url? Or have some fallback behavior? Terrible idea: we could have a list of known button repos and provide a selector / search interface when we can't detect the repo.

ahmetb commented 3 years ago

This was fixed now by GitHub.