-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
[REQUIRED] Environment info
firebase-tools: latest
Platform: macOS, GitHub action
[REQUIRED] Test case
We started having errors with deployments on GitHub actions, then I tried to replicate locally and got the same error. The final error we get on deploy is:
Error: Unable to parse JSON: SyntaxError: Unexpected token < in JSON at position 0
While debugging I found that listSites
here:
firebase-tools/src/hosting/runTags.ts
Line 25 in 73c4c96
const sites = await api.listSites(project); |
returns this object:
[
{
name: 'projects/<project-id>/sites/<site-id>',
defaultUrl: 'https://<project-id>.web.app/',
appId: '....',
type: 'DEFAULT_SITE'
}
]
Then, the URL that the Firebase CLI is calling here:
firebase-tools/src/hosting/runTags.ts
Line 26 in 73c4c96
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(site.name))); |
firebase-tools/src/hosting/api.ts
Lines 448 to 450 in 61523b9
const res = await apiClient.get<ListVersionsResponse>(`projects/-/sites/${site}/versions`, { | |
queryParams, | |
}); |
is:
https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/projects/<project-id>/sites/<site-id>/versions
Note /sites
showing up twice. Basically the URL is invalid so it’s 404ing, leading to a HTML 404 page from Hosting being returned in the API call, which expects a JSON.
This one works:
https://firebasehosting.googleapis.com/v1beta1/projects/-/sites/<site-id>/versions
I was able to deploy locally with #6565, however I don't know where the fix should be applied in case a similar problem occurs elsewhere.
[REQUIRED] Steps to reproduce
firebase deploy
[REQUIRED] Expected behavior
deploy works
[REQUIRED] Actual behavior
deploy errors out because of invalid URL in Hosting API