Gitea: Template exception when rendering file list

Created on 22 Apr 2019  路  13Comments  路  Source: go-gitea/gitea

Running version: b83114f

I have many repo's and most of them work fine, today I entered a small one and one specific branch would not load and gave me this exception:

template: repo/view_list:82:38: executing "repo/view_list" at <$commit.Summary>: invalid value; expected string

Related template file:
https://github.com/go-gitea/gitea/blob/b83114f1407247415b184f77f8f2f6ecea8cb994/templates/repo/view_list.tmpl#L82

I did a bit of research and it appears commits with a summary ending with a ' throw this exception. For instance:

Merge branch 'foo'

However this is fine:

Merge branch 'foo' into bar

kinbug prioritcritical

Most helpful comment

This is back to working on docker latest build. Thank you!

All 13 comments

can you reproduce this on try.gitea.io?

Unfortunately not, which is weird as it seemed to be consistent. I switched back to the latest stable release (1.8.0) which works fine.

It is weird though because it was only at that page where it loads the file list. The other views showing all commits worked fine.

Does it help to mention it is a mirrored repository and I am using docker? I'll see if I can recreate it locally using docker.

Repo on try.gitea.io: https://try.gitea.io/mdeboer/test

Try is also running in docker

When I was on gitea.com I found the same error on one of @lunny repos
https://gitea.com/lunny/wtf

I cloned lunnys repository and looked into that. Those files are causing the exception:

  • .editorconfig
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • LICENSE.md

commit_info.go calculates a mapping of file paths and file hashes. The files above are added to remainingPathsForParent and ultimately to the heap array. At some point they don't seem to be processed anymore.

Commit "37858d421073a878ffef2c308eb0c0bdd496960b" (Delete unused field from BarGraph widget) seems to have been visited already, which might be why the remaining files are not processed.
That's how far I've got... ^^

As pointed in my duplicate, the only file I have in my commit that matches the list is .editorconfig. There might be something with that one.

Problem is in func getLastCommitForPaths, some file tree entries does not get commit info assigned so that in the end we get error in template when accessing nil pointer properties.

@filipnavara this seems to be related to your code rewrite. Could you please check this out?

While debugging it seems to me that while traversing through commit parents result[path] does not get commit assigned but it does not get added to remaining paths to check either so it gets lost

EDIT: Or actually it could be that remainingPaths is empty and heap does not contain any more commits to check.

Just for info:
.editorconfig does not get info from commit 4d090042b56bd6b041a6d386563359d6463825b6 from
in repository https://github.com/wtfutil/wtf

Last checked commit in getLastCommitsForPaths is 568276343c727c21bee583cc7c2b8ce0e6dfdd89

I will look into it.

Removing the seen map from getLastCommitForPaths fixes it. It also makes it easier to reason about the correctness of the algorithm. Thanks to other changes made in #6686 it also doesn't noticably degrade performance. I have tested the change on the linked repositories and Rails and Linux repositories.

When can we see this in upstream? @lafriks, thank you for flagging this critical!

@bkraul fix has been merged, please test

@filipnavara thanks for fast fix 馃憤

This is back to working on docker latest build. Thank you!

Was this page helpful?
0 / 5 - 0 ratings