Gitea: Due date not saving when set via API

Created on 14 Sep 2019  路  10Comments  路  Source: go-gitea/gitea

  • Gitea version (or commit ref): 1.10.0+dev-288-g7a8e299c7
  • Git version: 2.11.0
  • Operating system: Devuan Ascii (Debian Stretch)
  • Database (use [x]):

    • [ ] PostgreSQL

    • [X] MySQL

    • [ ] MSSQL

    • [ ] SQLite

  • Can you reproduce the bug at https://try.gitea.io:

    • [X] Yes (provide example URL)

    • [ ] No

    • [ ] Not relevant

  • Log gist:

Description

When using API to set a due date the timeline shows it has been set, but the due date comes back null.

curl -X PATCH "https://xxx/api/v1/repos/jhodges/test/issues/11" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{ \"due_date\": \"2019-09-14T15:46:01.026Z\" }"

{"id":1116, ... "due_date":null, ...}

The same API call works just fine on try.gitea.io so it must be something local. Any ideas? edit: not true

Screenshots

You can see the timeline showing my attempts to add a date, yet still it is not shown in the due date field on the right bar.

2019-09-14-165952_1099x235_scrot

kinapi kinbug

Most helpful comment

I've found two bugs in the code

  • API is calling models.UpdateIssue which updates all columns, but the issue structure is not updated with new deadline
  • UpdateIssueDeadline is called even if form.Deadline is not set (causing an issue comment, but it is overwritten due to above point)

This affects at least issue and pull request update API. Creation API should also be checked.

All 10 comments

Oh and setting the date in the web interface works just fine

I've just tried a clean install: stop gitea, move aside config/data, dropping the db, starting gitea, recreating an admin user, repo, issue and testing again. Still the same problem.

Just tried this again but this time using SQLite. Same issue.

Also tried on try.gitea.io again and this time it is also NOT working!!

curl -X PATCH "https://bobemoe:[email protected]/api/v1/repos/bobemoe/test/issues/1" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{ \"due_date\": \"2019-10-15T16:46:01.026Z\" }"

I was either mistaken the first time or some regression has happened. Hmmm. I've updated the issue to reflect this new info.

Same issue on 1.9.3

OK, I'm tracking this down:

Seems there is a separate API endpoint for setting a "deadline" POST try.gitea.io/api/v1/repos/bobemoe/test/issues/1/deadline which sets the date just fine!

So why does this specific field have its own endpoint? And how come it half works (generates timeline message) when set with other fields on the "normal" endpoint?

So now my script is using the correct endpoint I'm having better luck setting due dates. Now I have noticed that if I PATCH the issue to change the issue body, that the timeline notice says I've removed the due date, even though due date was not in the post fields, and is not actually removed!

curl -X PATCH "https://bobemoe:[email protected]/api/v1/repos/bobemoe/test/issues/1" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"body\": \"test\"}"

Guess this is the same functionality that erroneously said I'd added a due date from above!

@bobemoe do you have permission of writing issues? The deadline only be set when users have write permission of issues unit. Otherwise it will be ignored.

I have also encountered this issue.

We have repo with issues disabled. When I try to set Due Date on pull request my API call result in 403 Forbidden. I also see red box with message: "The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'. "

Gitea ver: 1.10-rc1.

That doesn't quite sound like the issue I was describing... I don't get 403 or that message. What API call are you using?

I've found two bugs in the code

  • API is calling models.UpdateIssue which updates all columns, but the issue structure is not updated with new deadline
  • UpdateIssueDeadline is called even if form.Deadline is not set (causing an issue comment, but it is overwritten due to above point)

This affects at least issue and pull request update API. Creation API should also be checked.

Was this page helpful?
0 / 5 - 0 ratings