nedbat / scriv

Changelog management tool
https://scriv.readthedocs.io
Apache License 2.0
256 stars 28 forks source link

github-release raising 404 Client Error: Not Found for url on powershell #72

Closed henriquelino closed 1 year ago

henriquelino commented 1 year ago

Hello, when I use scriv github-release on powershell I get this output:

scriv github-release --verbosity debug
debug: Running command 'git remote -v'
debug: Command exited with 0 status. Output: 'origin\thttps://github.com/henriquelino/timer.git (fetch)\norigin\thttps://github.com/henriquelino/timer.git (push)\n'
debug: Running command 'git tag'
debug: Command exited with 0 status. Output: 'v0.1.0\nv0.1.0.2\nv0.1.0.3\nv0.1.0.4\nv0.1.0.5\n'
debug: Starting new HTTPS connection (1): api.github.com:443
debug: https://api.github.com:443 "GET /repos/henriquelino/timer/releases HTTP/1.1" 301 159
debug: https://api.github.com:443 "GET /repositories/577091747/releases HTTP/1.1" 200 995
Creating release v0.1.0.5
debug: Starting new HTTPS connection (1): api.github.com:443
debug: https://api.github.com:443 "POST /repos/henriquelino/timer/releases HTTP/1.1" 307 159
debug: https://api.github.com:443 "POST /repositories/577091747/releases HTTP/1.1" 404 None
error: text: '{"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#create-a-release"}'
Traceback (most recent call last):
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\Scripts\scriv.exe\__main__.py", line 7, in <module>
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\scriv\ghrel.py", line 67, in github_release
    create_release(repo, release_data)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\scriv\github.py", line 88, in create_release
    check_ok(resp)
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\scriv\github.py", line 24, in check_ok
    resp.raise_for_status()
  File "C:\Users\henri\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.github.com/repositories/577091747/releases

I couldn't find anything related neither could trace why this happens on powershell but not on git bash.

I am on Windows 10, python 3.9 and scriv 1.0.0, when running on git bash it works fine.

nedbat commented 1 year ago

Interesting! Since it is failing when trying to create the release, I will guess that on git bash, you have credentials in a GITHUB_TOKEN environment variable, but under Powershell you don't. Is that possible?

henriquelino commented 1 year ago

Yep that's exactly what was happening, I ran gci env:* | sort-object name and github token wasn't there, then I closed powershell and open again, then ran the command again, poof, github_token now shows and scriv github-release is working, thanks for the insight!

It seems that after changing system environments I should've restarted powershell, so it recognizes the new var.