Description deleted when task is closed via api

Hello,

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:

{"id":195,"title":"test","description":"","done":true,"done_at":"2022-10-24T10:08:45.366588817+02:00","due_date":"0001-01-01T00:00:00Z","reminder_dates":null,"list_id":3,"repeat_after":0,"repeat_mode":0,"priority":0,"start_date":"0001-01-01T00:00:00Z","end_date":"0001-01-01T00:00:00Z","assignees":[],"labels":null,"hex_color":"","percent_done":0,"identifier":"","index":41,"related_tasks":null,"attachments":null,"is_favorite":false,"created":"0001-01-01T00:00:00Z","updated":"2022-10-24T10:08:45+02:00","bucket_id":22,"position":0,"kanban_position":0,"created_by":null}

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.