~sircmpwn/todo.sr.ht#214: 
Updating ticket by status and resolution via API does not work

I am trying to update a ticket per the API docs by sending a PUT request to https://todo.sr.ht/api/user/~samwhited/trackers/mellium/tickets/3 which matches this API endpoint.

The body of my request contains:

{"status":"resolved","resolution":"fixed"}

The status and resolution fields are defined as specified on that API endpoint, however, I get multiple errors returned:

{Field:"status", Reason:"resolved is not a valid TicketStatus", statusCode:400}
{Field:"resolution", Reason:"fixed is not a valid TicketResolution", statusCode:400}

(err format is a Go struct the JSON was unmarshaled to, it should be obvious how it maps to the JSON fields but let me know if there's something missing you need and I'll find a way to bypass this SDK and get at the underlying JSON)

Status
REPORTED
Submitter
~samwhited
Assigned to
No-one
Submitted
a month ago
Updated
8 days ago
Labels
No labels applied.

~samwhited a month ago

The error appears to come from srht/validation.py:118. I don't understand what's going on well enough to know why things work this way, but the IntFlag class (which TicketStatus is) is a subclass of Enum so thsi branch is being selected even though value ends up being a string value which cannot be created with the IntFlag constructor. I should note that I haven't been able to get srht working locally to test this, I just made a python file taht creates a class and does the logic from this branch to see if the ValueError was hit.

~timetoplatypus 27 days ago

I'm writing a sr.ht client in Go and encountered this issue as well. I've tried a number of different values to send to this endpoint, and none have worked. From my brief investigation into the sr.ht codebase, I think the problem is rooted in the way Python serializes/deserializes enums; the endpoint requires an IntFlag but won't actually accept integers.

Additionally, with this endpoint, sending a null value for the labels field will trigger a HTTP 500 Internal Server Error. For example: curl -H "Authorization:token <sr.ht personal access token> " -H "Content-Type: application/json" -X PUT https://todo.sr.ht/api/user/<username>/trackers/<trackerName>/tickets/<trackerId> -d '{"labels": null}'

~samwhited 27 days ago

Amusingly, that is exactly what I was doing when I found this issue :) https://git.sr.ht/~samwhited/sourcehut-go

~timetoplatypus 8 days ago

I'm not on any sr.ht mailing lists or anything, so it's possible I'm out of the loop; have you heard anything about this ticket with regards to a fix or temporary workaround?

~samwhited 8 days ago

I have not heard anything, but I think the author is working on a new version of the API so this may be low priority. That's just a guess though.

Register here or Log in to comment, or comment via email.