Description deleted when task is closed via api


I noticed that the description is deleted when a task is closed (marked as completed) via API.

I close the task with curl in a way like:

curl -X POST "${URL}/tasks/${TASK_ID}" -H "Content-type:application/json" -H "Authorization: Bearer ${TOKEN}" -d '{"done":true}'

I got this response:


As a side note, dunno why created and created_by looks to be wrong.

reproduced on try as Vikunja

That’s actually intended behavior. The problem is in Go, I cant differentiate between “this field is empty” and “this field was not sent to the api”. Therefore the API treats all fields which are not passed as empty. So in fact, the request you sent does not only set the description to empty but every other field as well.

I understand your concern.

Is there something to work around this issue like send a custom header to say to not update the description or send a param like “update_description”: false ?

As said I understand your point but that’s a big limitation for api consumers.

Right now there’s no workaround available.

Ideally it could detect if the field was passed or not and respect that when doing the update. If anyone has ideas on how to achieve that I’m all ears.

Atm a workaround for my situation is fetch the description and pass it in the POST request togheter "done": true

That’s what the frontend does as well.

Wouldn’t it be possible to add support for PATCH?

Only changing the method won’t solve the problem. This is a go internal thing we need a workaround for.

Indeed. In general it would be good especially for tasks to have such an endpoint. Thinking here of all the cases where we post all fields of a task to the backend only to edit one. By modifying only what we change we reduce possible conflicts / overwrites.