Skip to content

[Error] AttributeError: 'StreamReader' object has no attribute 'lower' on 0.16.0 #365

Description

@guangyey

Hi @ezyang

When I use 0.15.0, it works well:

(stock) guangyey@guangye-a770:~/repos/stock-pytorch$ ghstack --version
ghstack, version 0.15.0
(stock) guangyey@guangye-a770:~/repos/stock-pytorch$ ghstack
$ git remote get-url --push origin
$ git cat-file -e HEAD:.github/ghstack_direct
fatal: path '.github/ghstack_direct' does not exist in 'HEAD'
$ git fetch --prune origin '+refs/heads/*:refs/remotes/origin/*'
$ git rev-list --header --topo-order --boundary HEAD '^origin/main'
$ git rev-list --boundary --header --topo-order HEAD 7d160524597cf06d5538591e2a89c4661e0f8f5b '^origin/main'
$ git rev-parse --show-toplevel
$ git config --default /home/guangyey/repos/stock-pytorch/.git/hooks --get core.hooksPath
$ git rev-list --max-count=1 --header origin/gh/guangyey/391/orig
$ git rev-list --header -1 origin/gh/guangyey/391/orig
$ git rev-list --header -1 origin/gh/guangyey/391/head
$ git rev-list --header -1 origin/gh/guangyey/391/base
$ git config --get commit.gpgsign
$ git commit-tree -p 526b9cee8c9ad8da312bf33ea2c3f308cbfe8876 cf22fcc3dffbb1d2aa1586125cd40025309ce616
$ git push origin --no-verify --force 12e5b9ada73b9aadc2c34c04b205b3e2a3f0468e:refs/heads/gh/guangyey/391/orig
remote: 
remote: GitHub found 24 vulnerabilities on pytorch/pytorch's default branch (14 high, 10 moderate). To find out more, visit:        
remote:      https://github.com/pytorch/pytorch/security/dependabot        
remote: 
To github.com:pytorch/pytorch.git
 + 7d160524597...12e5b9ada73 12e5b9ada73b9aadc2c34c04b205b3e2a3f0468e -> gh/guangyey/391/orig (forced update)
# Updating https://github.com/pytorch/pytorch/pull/191006

# Summary of changes (ghstack 0.15.0)

 - Skipped https://github.com/pytorch/pytorch/pull/191006

Meta employees can import your changes by running 
(on a Meta machine):

    ghimport -s https://github.com/pytorch/pytorch/pull/191006

If you want to work on this diff stack on another machine:

    ghstack checkout https://github.com/pytorch/pytorch/pull/191006

$ git rev-parse HEAD
$ git reset --soft 12e5b9ada73b9aadc2c34c04b205b3e2a3f0468e

When upgrading to 0.16.0, it raises an AttributeError :

stock) guangyey@guangye-a770:~/repos/stock-pytorch$ ghstack --version
ghstack, version 0.16.0
(stock) guangyey@guangye-a770:~/repos/stock-pytorch$ ghstack
$ git remote get-url --push origin
$ git rev-parse --git-dir
$ git cat-file -e HEAD:.github/ghstack_direct
fatal: path '.github/ghstack_direct' does not exist in 'HEAD'
$ git fetch --prune origin '+refs/heads/gh/guangyey/*:refs/remotes/origin/gh/guangyey/*'
$ git rev-list --header --topo-order --boundary HEAD '^origin/main'
$ git rev-list --boundary --header --topo-order HEAD 12e5b9ada73b9aadc2c34c04b205b3e2a3f0468e '^origin/main'
$ git rev-parse --show-toplevel
$ git config --default /home/guangyey/repos/stock-pytorch/.git/hooks --get core.hooksPath
$ git rev-list --max-count=1 --header origin/gh/guangyey/391/orig
$ git rev-list --header -1 origin/gh/guangyey/391/orig
$ git rev-list --header -1 origin/gh/guangyey/391/head
$ git rev-list --header -1 origin/gh/guangyey/391/base
$ git config --get commit.gpgsign
$ git commit-tree -p 526b9cee8c9ad8da312bf33ea2c3f308cbfe8876 cf22fcc3dffbb1d2aa1586125cd40025309ce616
$ git push origin --no-verify +db00e45181b5e9d93a3e71292232645c9154b2d0:refs/heads/gh/guangyey/391/orig
remote: 
remote: GitHub found 24 vulnerabilities on pytorch/pytorch's default branch (14 high, 10 moderate). To find out more, visit:        
remote:      https://github.com/pytorch/pytorch/security/dependabot        
remote: 
To github.com:pytorch/pytorch.git
 + 5fe1aac3e05...db00e45181b db00e45181b5e9d93a3e71292232645c9154b2d0 -> gh/guangyey/391/orig (forced update)
# Updating https://github.com/pytorch/pytorch/pull/191006
ERROR: Fatal exception
Traceback (most recent call last):
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/logs.py", line 245, in manager
    yield
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/cli.py", line 65, in cli_context
    yield shell, config, github
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/cli.py", line 537, in submit
    run_async(
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/cli.py", line 35, in run_async
    return asyncio.run(coro)
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/cli.py", line 43, in run_with_github
    return await coro
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/submit.py", line 349, in main
    return await submitter.run()
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/submit.py", line 659, in run
    await self.push_updates(diffs_to_submit, all_diffs=all_diffs_in_topo_order)
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/submit.py", line 2103, in push_updates
    await _gather_ordered(_update_pr_async(s) for s in reversed(diffs_to_submit))
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/submit.py", line 331, in _gather_ordered
    raise result
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/submit.py", line 2092, in _update_pr_async
    await self.github.arest("patch", path, **kwargs)
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/site-packages/ghstack/github_real.py", line 254, in arest
    elif b"rate limit" in resp.content.lower():
AttributeError: 'StreamReader' object has no attribute 'lower'

After applying the fix #364, it raises the Error message to remind me that the token has no permission to access.

remote: 
remote: GitHub found 24 vulnerabilities on pytorch/pytorch's default branch (14 high, 10 moderate). To find out more, visit:        
remote:      https://github.com/pytorch/pytorch/security/dependabot        
remote: 
To github.com:pytorch/pytorch.git
 + 74600a2c86a...1e010c123ed 1e010c123ed88c509a2f0e247dc096fca453a9be -> gh/guangyey/391/orig (forced update)
# Updating https://github.com/pytorch/pytorch/pull/191006
ERROR: Fatal exception
Traceback (most recent call last):
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/logs.py", line 245, in manager
    yield
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/cli.py", line 65, in cli_context
    yield shell, config, github
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/cli.py", line 537, in submit
    run_async(
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/cli.py", line 35, in run_async
    return asyncio.run(coro)
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/guangyey/miniforge3/envs/stock/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/cli.py", line 43, in run_with_github
    return await coro
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/submit.py", line 349, in main
    return await submitter.run()
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/submit.py", line 659, in run
    await self.push_updates(diffs_to_submit, all_diffs=all_diffs_in_topo_order)
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/submit.py", line 2103, in push_updates
    await _gather_ordered(_update_pr_async(s) for s in reversed(diffs_to_submit))
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/submit.py", line 331, in _gather_ordered
    raise result
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/submit.py", line 2092, in _update_pr_async
    await self.github.arest("patch", path, **kwargs)
  File "/home/guangyey/.local/share/uv/tools/ghstack/lib/python3.10/site-packages/ghstack/github_real.py", line 290, in arest
    raise RuntimeError(pretty_json)
RuntimeError: {
 "message": "Resource not accessible by personal access token",
 "documentation_url": "https://docs.github.com/rest/pulls/pulls#update-a-pull-request",
 "status": "403"
}

After I switched my token from fine-grained to classic with permission repo and workflow, it finally works:

gh(stock) guangyey@guangye-a770:~/repos/stock-pytorch$ ghstack
$ git remote get-url --push origin
$ git rev-parse --git-dir
$ git cat-file -e HEAD:.github/ghstack_direct
fatal: path '.github/ghstack_direct' does not exist in 'HEAD'
$ git fetch --prune origin '+refs/heads/gh/guangyey/*:refs/remotes/origin/gh/guangyey/*'
$ git rev-list --header --topo-order --boundary HEAD '^origin/main'
$ git rev-list --boundary --header --topo-order HEAD e06579d011808e7567b447cf34b8b51714e4f513 '^origin/main'
$ git rev-parse --show-toplevel
$ git config --default /home/guangyey/repos/stock-pytorch/.git/hooks --get core.hooksPath
$ git rev-list --max-count=1 --header origin/gh/guangyey/391/orig
$ git rev-list --header -1 origin/gh/guangyey/391/orig
$ git rev-list --header -1 origin/gh/guangyey/391/head
$ git rev-list --header -1 origin/gh/guangyey/391/base
$ git config --get commit.gpgsign
$ git commit-tree -p 526b9cee8c9ad8da312bf33ea2c3f308cbfe8876 cf22fcc3dffbb1d2aa1586125cd40025309ce616
$ git push origin --no-verify +717a66a3d9564b9503189ef8f909db21b5030513:refs/heads/gh/guangyey/391/orig
remote: 
remote: GitHub found 24 vulnerabilities on pytorch/pytorch's default branch (14 high, 10 moderate). To find out more, visit:        
remote:      https://github.com/pytorch/pytorch/security/dependabot        
remote: 
To github.com:pytorch/pytorch.git
 + e06579d0118...717a66a3d95 717a66a3d9564b9503189ef8f909db21b5030513 -> gh/guangyey/391/orig (forced update)
# Updating https://github.com/pytorch/pytorch/pull/191006

# Summary of changes (ghstack 0.16.0)

 - Skipped https://github.com/pytorch/pytorch/pull/191006

Meta employees can import your changes by running 
(on a Meta machine):

    ghimport -s https://github.com/pytorch/pytorch/pull/191006

If you want to work on this diff stack on another machine:

    ghstack checkout https://github.com/pytorch/pytorch/pull/191006

$ git rev-parse HEAD
$ git reset --soft 717a66a3d9564b9503189ef8f909db21b5030513
[ghstack timing] fetch: 5327ms
[ghstack timing] parse_revs: 20ms
[ghstack timing] prepare_updates: 2078ms
[ghstack timing] push_updates: 9098ms
[ghstack timing] finalize: 21ms
[ghstack timing] total: 16543ms

Summary:
If the user uses a fine-grained token with 0.16.0, ghstack will raise AttributeError: 'StreamReader' object has no attribute 'lower' and the user don't know that they should switch to classic token with permission repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions