grip: GRIP (possible regression) giving me an error for some reason

Getting an error and I don’t know why. I thought it was because I had a circular link (like a link from A --> B and from B --> A) but then I removed it and it still didn’t work. Details below

      Kernel Version: Darwin 23.3.0
      Python 3.12 or so...
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 1463, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 872, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 870, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 855, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/grip/app.py", line 190, in _render_page
    content = self.renderer.render(text, self.auth)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/grip/renderers.py", line 79, in render
    r.raise_for_status()
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 415 Client Error: Unsupported Media Type for url: https://api.github.com/markdown/raw
127.0.0.1 - - [05/Mar/2024 17:29:45] "GET / HTTP/1.1" 500 -
[2024-03-05 17:29:45,875] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 1463, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 872, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 870, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/flask/app.py", line 855, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/grip/app.py", line 190, in _render_page
    content = self.renderer.render(text, self.auth)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/grip/renderers.py", line 79, in render
    r.raise_for_status()
  File "/opt/homebrew/Cellar/grip/4.6.2_3/libexec/lib/python3.12/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 415 Client Error: Unsupported Media Type for url: https://api.github.com/markdown/raw
127.0.0.1 - - [05/Mar/2024 17:29:45] "GET / HTTP/1.1" 500 -

About this issue

  • Original URL
  • State: open
  • Created 4 months ago
  • Reactions: 9
  • Comments: 18 (2 by maintainers)

Most upvoted comments

Hi folks, GitHub employee here. Just wanted to report that the API issue is now resolved, and unauthenticated requests to the markdown/raw endpoint are working again. A change was pushed to a caching layer last week that inadvertently resulted in issues with the incoming Content-Type header, but that bug has been fixed.

Thanks for bringing this to our attention, and apologies for the trouble!

I’ve got a ticket open with GH support, will report back if I find out anything useful.

Update from GitHub support: they confirmed this issue exists and I am waiting on an update from engineering.

Or, more easily, you could set username and password in ~/.grip/settings.py.

The error page body is:

{"message":"Invalid request media type (expecting 'text/plain')","documentation_url":"https://docs.github.com/rest/markdown/markdown#render-a-markdown-document-in-raw-mode"}

But setting Content-Type to text/plain doesn’t fix it. Smells like a problem on the GitHub side.

In the mean time, --user-content still works, but IIRC it’s slightly different rendering.

Just ran into this, thank you for the feedback and support, all! I can confirm that

grip --user=<username> --pass=''

indeed is a workaround at the moment.

If the --user option is used then it seems to work.

This is a valid workaround. Works also for me when using the empty personal token via --pass option as described in the README: https://github.com/joeyespo/grip?tab=readme-ov-file#access . HTH for the time being.

If the --user option is used then it seems to work.

I have kind of a hacky workaround using directly the github api with gh:

gh api  \
 --method POST   \
 -H "Accept: application/vnd.github+json"   \
 -H "X-GitHub-Api-Version: 2022-11-28"   \
  /markdown   \
  -f text="$(cat README.md)" > readme.html

Then open readme.html locally.

⚠️ gh must be logged to your github account.

Just ran into this, thank you for the feedback and support, all! I can confirm that

grip --user=<username> --pass=''

indeed is a workaround at the moment.

As is

grip --pass=$(cat /path/to/github_token)

where my github personal token is stored in /path/to/github_token

Same here, feels like a regression in the REST API.