Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
howdoicomputer opened this issue Sep 26, 2018 · 8 comments

Comments

@howdoicomputer
Copy link

commented 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.

@howdoicomputer

This comment has been minimized.

Copy link
Author

commented 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

This comment has been minimized.

Copy link
Author

commented Sep 26, 2018

This is an upstream issue: chaseadamsio/goorgeous#82

Goorgeous cannot parse org files with empty headerlines.

@yasuokav yasuokav referenced this issue Jan 30, 2019

Closed

org problem with file #5898

2 of 7 tasks complete
@zeripath

This comment has been minimized.

Copy link
Contributor

commented 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)

@adelowo

This comment has been minimized.

Copy link
Member

commented 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

m.Use(macaron.Recovery())

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

@zeripath

This comment has been minimized.

Copy link
Contributor

commented Jan 30, 2019

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

@igor9292

This comment has been minimized.

Copy link

commented Jan 30, 2019

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

zeripath added a commit to zeripath/gitea that referenced this issue Jan 30, 2019

Recover panic in orgmode.Render if bad orgfile (go-gitea#4982)
This PR protects against the panic referred to in chaseadmsio/goorgeous#82
by recovering from the panic and just returning the raw bytes if
there is an error.

Signed-off-by: Andrew Thornton <art27@cantab.net>

@zeripath zeripath added in progress and removed status/blocked labels Jan 30, 2019

@zeripath

This comment has been minimized.

Copy link
Contributor

commented 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.

@howdoicomputer

This comment has been minimized.

Copy link
Author

commented Jan 30, 2019

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

#5710

techknowlogick added a commit that referenced this issue Jan 30, 2019

Recover panic in orgmode.Render if bad orgfile (#4982) (#5903)
This PR protects against the panic referred to in chaseadmsio/goorgeous#82
by recovering from the panic and just returning the raw bytes if
there is an error.

Signed-off-by: Andrew Thornton <art27@cantab.net>

zeripath added a commit to zeripath/gitea that referenced this issue Feb 16, 2019

Recover panic in orgmode.Render if bad orgfile (go-gitea#4982) (go-gi…
…tea#5903)

This PR protects against the panic referred to in chaseadmsio/goorgeous#82
by recovering from the panic and just returning the raw bytes if
there is an error.

Signed-off-by: Andrew Thornton <art27@cantab.net>

techknowlogick added a commit that referenced this issue Feb 16, 2019

Recover panic in orgmode.Render if bad orgfile (#4982) (#5903) (#6097)
This PR protects against the panic referred to in chaseadmsio/goorgeous#82
by recovering from the panic and just returning the raw bytes if
there is an error.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Mikescher added a commit to Mikescher/gitea that referenced this issue Mar 20, 2019

Recover panic in orgmode.Render if bad orgfile (go-gitea#4982) (go-gi…
…tea#5903)

This PR protects against the panic referred to in chaseadmsio/goorgeous#82
by recovering from the panic and just returning the raw bytes if
there is an error.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.