PANIC: index out of range when viewing org file in repository #2358

Closed
opened 2025-11-02 04:33:46 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @howdoicomputer on GitHub (Sep 26, 2018).

Description

I checked in an org file to a private repository. I'm able to pull the file and view the diff but rendering it in the web view produces a blank page and stack trace.

Originally created by @howdoicomputer on GitHub (Sep 26, 2018). - Gitea version (or commit ref): 1.5.1 - Git version: 2.14.1 - Operating system: Ubuntu 17.04 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes: https://try.gitea.io/howdoicomputer/org-test - [ ] No - [ ] Not relevant - Log gist: https://gist.github.com/howdoicomputer/4b85078aea5750c042bd7b9292d7f65f ## Description I checked in an org file to a private repository. I'm able to pull the file and view the diff but rendering it in the web view produces a blank page and stack trace.
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 04:33:46 -06:00
Author
Owner

@howdoicomputer commented on GitHub (Sep 26, 2018):

It looks like Gitea fails to render if goorgeous fails to parse. I pushed a simpler test.org file and it rendered fine.

@howdoicomputer commented on GitHub (Sep 26, 2018): It looks like Gitea fails to render if goorgeous fails to parse. I pushed a simpler test.org file and it rendered fine.
Author
Owner

@howdoicomputer commented on GitHub (Sep 26, 2018):

This is an upstream issue: https://github.com/chaseadamsio/goorgeous/issues/82

Goorgeous cannot parse org files with empty headerlines.

@howdoicomputer commented on GitHub (Sep 26, 2018): This is an upstream issue: https://github.com/chaseadamsio/goorgeous/issues/82 Goorgeous cannot parse org files with empty headerlines.
Author
Owner

@zeripath commented on GitHub (Jan 30, 2019):

Ok, although the original cause of this bug is in an upstream library - now that we know about it we should recover from panics within that library and just render the text with an error.

See https://blog.golang.org/defer-panic-and-recover

We should also have a root handler for Macaron that does a similar recover and returns a gitea 500. Probably with two different levels of information depending on the production mode. (I.e. report stack trace or not)

@zeripath commented on GitHub (Jan 30, 2019): Ok, although the original cause of this bug is in an upstream library - now that we know about it we should recover from panics within that library and just render the text with an error. See https://blog.golang.org/defer-panic-and-recover We should also have a root handler for Macaron that does a similar recover and returns a gitea 500. Probably with two different levels of information depending on the production mode. (I.e. report stack trace or not)
Author
Owner

@adelowo commented on GitHub (Jan 30, 2019):

@zeripath There is already a handler for recovery. I believe the application should keep on
running. I have run into a few waves of panic too

a967cf9e99/routers/routes/routes.go (L55)

https://github.com/go-macaron/docs/blob/master/en-US/middlewares/core_services.md

@adelowo commented on GitHub (Jan 30, 2019): @zeripath There is already a handler for recovery. I believe the application should keep on running. I have run into a few waves of panic too https://github.com/go-gitea/gitea/blob/a967cf9e99461bbd89b8b26fd41faf9f4ed06010/routers/routes/routes.go#L55 https://github.com/go-macaron/docs/blob/master/en-US/middlewares/core_services.md
Author
Owner

@zeripath commented on GitHub (Jan 30, 2019):

Ah but that is not good enough - the user gets a blank page.

@zeripath commented on GitHub (Jan 30, 2019): Ah but that is not good enough - the user gets a blank page.
Author
Owner

@igor9292 commented on GitHub (Jan 30, 2019):

colleagues, and you can make the file appear just text,
file was displayed without formatting?

@igor9292 commented on GitHub (Jan 30, 2019): colleagues, and you can make the file appear just text, file was displayed without formatting?
Author
Owner

@zeripath commented on GitHub (Jan 30, 2019):

I'm removing the status/blocked label. Yes we can't prevent goorgeous from having a panic but we can damned well stop that propogating - and we should. I've put a PR up to recover from the panic and just return the original byte array as plain text. This is the simplest thing to do but is perhaps a little unfriendly - another solution might be to return "Unable to render" instead.

@zeripath commented on GitHub (Jan 30, 2019): I'm removing the `status/blocked` label. Yes we can't prevent goorgeous from having a `panic` but we can damned well stop that propogating - and we should. I've put a PR up to recover from the panic and just return the original byte array as plain text. This is the simplest thing to do but is perhaps a little unfriendly - another solution might be to return "Unable to render" instead.
Author
Owner

@howdoicomputer commented on GitHub (Jan 30, 2019):

There is also this open issue that suggests replacing goorgeous with another library.

https://github.com/go-gitea/gitea/issues/5710

@howdoicomputer commented on GitHub (Jan 30, 2019): There is also this open issue that suggests replacing goorgeous with another library. https://github.com/go-gitea/gitea/issues/5710
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2358