"call of nil" exception when comparing images #3976

Closed
opened 2025-11-02 05:32:23 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @saitho on GitHub (Sep 18, 2019).

Description

Opening a pull request that adds or modifies an image works fine.

However in the file view of the pull request an error is thrown:

template: repo/diff/image_diff:14:29: executing "repo/diff/image_diff" at <call .root.FileExistsInBaseCommit .file.OldName>: error calling call: call of nil

Originally created by @saitho on GitHub (Sep 18, 2019). - Gitea version (or commit ref): master - Can you reproduce the bug at https://try.gitea.io: - [x] Yes: https://try.gitea.io/saitho/test2/pulls/3/files ## Description Opening a pull request that adds or modifies an image works fine. However in the file view of the pull request an error is thrown: > template: repo/diff/image_diff:14:29: executing "repo/diff/image_diff" at <call .root.FileExistsInBaseCommit .file.OldName>: error calling call: call of nil
GiteaMirror added the type/bug label 2025-11-02 05:32:23 -06:00
Author
Owner

@egrekov commented on GitHub (Sep 25, 2019):

Today I caught a similar error when opening a commit.
template: repo/diff/image_diff:14:29: executing "repo/diff/image_diff" at <call .root.FileExistsInBaseCommit .file.OldName>: error calling call: call of nil

© Gitea Version: 1.10.0+dev-326-gc05b89a5a

@egrekov commented on GitHub (Sep 25, 2019): Today I caught a similar error when opening a commit. `template: repo/diff/image_diff:14:29: executing "repo/diff/image_diff" at <call .root.FileExistsInBaseCommit .file.OldName>: error calling call: call of nil` `© Gitea Version: 1.10.0+dev-326-gc05b89a5a`
Author
Owner

@guillep2k commented on GitHub (Sep 26, 2019):

@saitho The easiest way to reproduce this problem is to check a commit that adds an image. The problem is that the commit URL is: /{user}/{repo}/commit/{commit-sha}, and this routes into:

f8882f4fa9/routers/repo/commit.go (L193)

Diff() does not set FileExistsInBaseCommit (or other image information), nor calls PrepareCompareDiff(), thus the error.

I've noticed that you've authored #6784 . Is it possible for you to create a new PR fixing this problem?

Perhaps a temporary workaround is to change:

f8882f4fa9/templates/repo/diff/box.tmpl (L113-L115)

Into something like:

{{if and $isImage ($root.FileExistsInBaseCommit != nil)}}
	{{template "repo/diff/image_diff" dict "file" . "root" $}}
{{else}}

Or something around those lines (I'm not quite familiar with macaron syntax).

@guillep2k commented on GitHub (Sep 26, 2019): @saitho The easiest way to reproduce this problem is to check a commit that adds an image. The problem is that the commit URL is: `/{user}/{repo}/commit/{commit-sha}`, and this routes into: https://github.com/go-gitea/gitea/blob/f8882f4fa909905311de86e80175184954464dc1/routers/repo/commit.go#L193 `Diff()` does not set `FileExistsInBaseCommit` (or other image information), nor calls `PrepareCompareDiff()`, thus the error. I've noticed that you've authored #6784 . Is it possible for you to create a new PR fixing this problem? Perhaps a temporary workaround is to change: https://github.com/go-gitea/gitea/blob/f8882f4fa909905311de86e80175184954464dc1/templates/repo/diff/box.tmpl#L113-L115 Into something like: ``` {{if and $isImage ($root.FileExistsInBaseCommit != nil)}} {{template "repo/diff/image_diff" dict "file" . "root" $}} {{else}} ``` Or something around those lines (I'm not quite familiar with macaron syntax).
Author
Owner

@saitho commented on GitHub (Sep 26, 2019):

Thanks for your analysis. I added the missing lines (probably lost while rebasing branches) and did some minor adjustments to the image compare functionality. :D

@saitho commented on GitHub (Sep 26, 2019): Thanks for your analysis. I added the missing lines (probably lost while rebasing branches) and did some minor adjustments to the image compare functionality. :D
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3976