Skip to content

"call of nil" exception when comparing images #8226

Closed

Description

@saitho

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

Activity

  1. added this to the 1.10.0 milestone on Sep 18, 2019
  2. egrekov commented on Sep 25, 2019

    @egrekov

    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

  3. guillep2k commented on Sep 26, 2019

    @guillep2k
    Member

    @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:

    func Diff(ctx *context.Context) {

    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:

    {{if $isImage}}
    {{template "repo/diff/image_diff" dict "file" . "root" $}}
    {{else}}

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

  4. saitho commented on Sep 26, 2019

    @saitho
    ContributorAuthor

    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

  5. locked and limited conversation to collaborators on Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions