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:


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)

Assigned to
3 years ago
3 years ago
No labels applied.

~samwhited 3 years 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 3 years 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 3 years ago

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

~timetoplatypus 3 years 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 3 years 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.