gitea: template error in issues list when poster_id is -1

  • Gitea version (or commit ref): 1.10.0+14-gc01afd584
  • Git version: 2.20.1
  • Operating system: Debian 10
  • Database:
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

template: repo/issue/list:236:26: executing "repo/issue/list" at <.Poster.ID>: nil pointer evaluating *models.User.ID

Description

Deleted owners issues sometimes get poster_id=-1 in issue table, leading to a template error in ./templates/repo/issue/list.tmpl in the issue list

This happened for 5 issues on codeberg.org, in an organization where users create one-time accounts for one single interaction, then delete it (I won’t comment on that, not my idea), but that fluctuation seems to make the error much more likely.

I am willing to fix the template IF you tell me that -1 is expected, if it is not then we have to find out why poster_id gets set to -1. Or is it rather a bug that deleted users poster_id do NOT get to -1?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (28 by maintainers)

Commits related to this issue

Most upvoted comments

@mrsdizzie @lunny @techknowlogick CONFIRMED! I can reproduce the issue easily, and yes poster_id becomes -1. Via API (I used gitnex from my phone), close an issue that was opened by a deleted user. That’s all.

@mrsdizzie

The reason why I believe that it happens afterwards is that it happend after issues got closed, and the time between opening and closing were 3 months for some issues. If it had been -1 upon creation the bug would have been triggered much earlier.

Enough said, we have to do more logging

@ashimokawa both options work for a solution, just one is better as with template it would just hide the underlying problem.

I just searched gitea.com and try.gitea.io DB and couldn’t find any poster_id of -1.

The poster_id should not be < 0, as template is just saying that it received nil as a user which means that what is being supplied to the template is incorrect. As when ghost is provided that is technically a valid user, so template is ok assuming everything passed to it won’t be nil. If I’m a bit rambly, the -1 id is the bug, not the template.