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

firebase init exit in 404 Error when both Hosting and GitHub Actions are selected #3742

Closed
os1ma opened this issue Sep 9, 2021 · 5 comments · Fixed by #3838
Closed

firebase init exit in 404 Error when both Hosting and GitHub Actions are selected #3742

os1ma opened this issue Sep 9, 2021 · 5 comments · Fixed by #3838

Comments

@os1ma
Copy link
Contributor

os1ma commented Sep 9, 2021

[REQUIRED] Environment info

firebase-tools:

9.18.0

Platform:

Ubuntu 20.04.3 LTS

[REQUIRED] Test case

See the reproduction procedure below.

[REQUIRED] Steps to reproduce

  1. Run firebase init.
  2. Select following two features.
    • "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys"
    • "Hosting: Set up GitHub Action deploys".
  3. Answer all the questions with YES or use the default values for all file names and other information.

[REQUIRED] Expected behavior

It should be able to complete the configuration successfully without error exit.

Fundamentally, the problem may be that the hosting configuration includes the GitHub Actions configuration, and there is a separate GitHub Actions configuration option.

[REQUIRED] Actual behavior

The setup for "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys" will be completed successfully.

During the setup of "Hosting: Set up GitHub Action deploys", the following error occurs.

Waiting for authentication...

✔  Success! Logged into GitHub as os1ma


Error: HTTP Error: 404, Not Found
@os1ma
Copy link
Contributor Author

os1ma commented Sep 9, 2021

I have investigated the cause of this issue.

Debug log

I ran the same procedure with the firebase init --debug command and got the following output.

✔  Success! Logged into GitHub as os1ma 

[2021-09-09T06:47:12.325Z] >>> [apiv2][query] GET https://api.github.com/repos/undefined [none]
[2021-09-09T06:47:12.558Z] <<< [apiv2][status] GET https://api.github.com/repos/undefined 404
[2021-09-09T06:47:12.559Z] <<< [apiv2][body] GET https://api.github.com/repos/undefined {"message":"Not Found","documentation_url":"https://docs.github.com/rest"}

Error: HTTP Error: 404, Not Found
[2021-09-09T06:47:12.564Z] Error Context: {
  "body": {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest",
    "error": {
      "message": "Not Found"
    }
  },
  "response": {
    "statusCode": 404
  }
}

As you can see https://api.github.com/repos/undefined, this is due to a request for an undefined repository name.

The relevant part of the source code

This occurs in the following places in the source code.

const { repo } = await prompt(options, [

The prompt function called here will not let you retype the values contained in the argument named options.

Therefore, if the GitHub Actions setting is executed twice, the return value of the promptForRepo function will be { "repo": undefined, "key": "", "keyId": "" } the second time.

And this will cause a 404 error.

The root cause and proposal

The root cause is that initGitHub function will be called twice when both "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys" and "Hosting: Set up GitHub Action deploys" are selected.

How about modifying it to ignore "Hosting: Set up GitHub Action deploys" if the both options are selected?

@arnav-kr
Copy link

Facing the same issue 😐

@khteh
Copy link

khteh commented Oct 11, 2021

Same error:

✔  Success! Logged into GitHub as <username>

[2021-10-11T02:34:50.914Z] >>> [apiv2][query] GET https://api.github.com/repos/undefined [none]
[2021-10-11T02:34:51.204Z] <<< [apiv2][status] GET https://api.github.com/repos/undefined 404
[2021-10-11T02:34:51.204Z] <<< [apiv2][body] GET https://api.github.com/repos/undefined {"message":"Not Found","documentation_url":"https://docs.github.com/rest"}

Error: HTTP Error: 404, Not Found
[2021-10-11T02:34:51.253Z] Error Context: {
  "body": {
    "message": "Not Found",
    "documentation_url": "https://docs.github.com/rest",
    "error": {
      "message": "Not Found"
    }
  },
  "response": {
    "statusCode": 404
  }
}

@Matrosskin
Copy link

@os1ma why do you need both features?

  • "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys"
  • "Hosting: Set up GitHub Action deploys".

As I understand, the second one is a part of the first one, so you do not need to select second feature. But I agree that selecting of both features should not broke the tool.

@os1ma
Copy link
Contributor Author

os1ma commented Oct 16, 2021

@Matrosskin Hi! Actually, I am not sure about the reason why both features are needed. It's just my guess, but the "Hosting: Set up GitHub Action deploys" option might be useful, if you want to add only GitHub Actions configuration later to an existing project.

In any case, it should not terminate in error, so I will create a simple pull request to resolve this issue.

bkendall added a commit that referenced this issue Nov 2, 2021
* Ignore setup GitHub Actions if hosting also selected

* Add a line to CHANGELOG.md

Co-authored-by: Bryan Kendall <bkend@google.com>
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this issue Dec 14, 2021
…irebase#3838)

* Ignore setup GitHub Actions if hosting also selected

* Add a line to CHANGELOG.md

Co-authored-by: Bryan Kendall <bkend@google.com>
kroikie pushed a commit that referenced this issue Mar 4, 2022
* Ignore setup GitHub Actions if hosting also selected

* Add a line to CHANGELOG.md

Co-authored-by: Bryan Kendall <bkend@google.com>
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.

4 participants