hypothesis / h

Annotate with anyone, anywhere.
https://hypothes.is/
BSD 2-Clause "Simplified" License
2.94k stars 427 forks source link

Group API `type` param 2/n: set `group.pubid` before returning open groups #8909

Closed seanh closed 4 weeks ago

seanh commented 1 month ago

GroupCreateService.create_private_group() and GroupCreateService.create_restricted_group() both return models.Group objects whose pubid attribute has already been generated, but GroupCreateService.create_open_group() returns groups with pubid=None because the value for pubid won't be generated until the group is flushed to the DB.

This is a likely source of errors (for example the API returning id: null in the JSON response when creating an open group) so fix GroupCreateService to generate pubid's also for open groups before returning the group to the caller.