Skip to content

Times API breaks after deleting repo containing issues with tracked times #10280

@bobemoe

Description

@bobemoe
  • Gitea version (or commit ref): 1.12.0+dev-307-g62a1322cf
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

After deleting a repo the times API has become unusable:

$ curl -X GET "https://bobemoe:xxxx@try.gitea.io/api/v1/user/times" -H  "accept: application/json"
{"message":"issue does not exist [id: 9010, repo_id: 0, index: 0]","url":"https://try.gitea.io/api/swagger"}

I've checked the DB and indeed the issue records for the deleted repo have been deleted but there are still records in the tracked_time table that now have a non-existent issue_id:

mysql> select t.*,i.id from tracked_time t left join issue i on t.issue_id=i.id having i.id is null;
+----+----------+---------+--------------+-------+---------+------+
| id | issue_id | user_id | created_unix | time  | deleted | id   |
+----+----------+---------+--------------+-------+---------+------+
|  3 |     1361 |       1 |   1571125831 |  3600 |       0 | NULL |
|  4 |     1361 |       1 |   1571125838 |  1500 |       0 | NULL |
....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions