ezyang / ezyang/ghstack

`ghstack land` doesn't work on private non-pro repositories

Open
#249 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1k
Forks
84
PR merge metrics
No merged PRs in 30d

Description

Hi ghstack team,

During my playing around with ghstack in a private repository I found that ghstack land won't work on private repositories that don't have GitHub Pro.

This is the error message I'm receiving when trying to land a PR:

ghstack land https://github.com/Artamus/stacked-diff-test/pull/10
ERROR: Fatal exception
Traceback (most recent call last):
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/github_real.py", line 198, in rest
    resp.raise_for_status()
  File "/home/artamus/.local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.github.com/repos/Artamus/stacked-diff-test/branches/main/protection

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/logs.py", line 105, in manager
    yield
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/cli.py", line 46, in cli_context
    yield shell, config, github
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/cli.py", line 135, in land
    ghstack.land.main(
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/land.py", line 72, in main
    protection = github.get(
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/github.py", line 67, in get
    return self.rest("get", path, **kwargs)
  File "/home/artamus/.local/lib/python3.10/site-packages/ghstack/github_real.py", line 200, in rest
    raise RuntimeError(pretty_json)
RuntimeError: {
 "message": "Upgrade to GitHub Pro or make this repository public to enable this feature.",
 "documentation_url": "https://docs.github.com/rest/branches/branch-protection#get-branch-protection"
}

To reproduce, simply create a private repository and try to create a stack of 2 commits and land them with ghstack.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ghstack/land.py around line 72 and trace the branch-protection request through ghstack/github.py and ghstack/github_real.py. Reproduce the failure with a private non-Pro repository and verify that ghstack land handles the GitHub 403 response appropriately instead of terminating with the shown fatal exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, python
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.