Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bodhi's REST API should separate the create and edit endpoints #2208

Open
bowlofeggs opened this issue Mar 8, 2018 · 7 comments · Fixed by #2464
Open

Bodhi's REST API should separate the create and edit endpoints #2208

bowlofeggs opened this issue Mar 8, 2018 · 7 comments · Fixed by #2464
Labels
API Issues related to Bodhi's REST API Backwards incompatible The proposed change is backwards incompatible and should wait for the next major release High priority These issues are higher priority than normal
Projects

Comments

@bowlofeggs
Copy link
Contributor

While working on #1814 today I discovered that the REST API will set an update's severity to "unspecified" if the POST data does not include the severity field. This means that users who edit an update with the CLI and don't specify a --severity will end up altering the update to reset its severity to "unspecified".

@bowlofeggs bowlofeggs added API Issues related to Bodhi's REST API High priority These issues are higher priority than normal labels Mar 8, 2018
@bowlofeggs
Copy link
Contributor Author

It turns out that it's not just severity that gets reset, but all fields get reset if not specified in a follow-on post. If I use the CLI to change an update to have a stable karma of 5 and then use it to make a different change and don't specify that karma, it gets set back to 3 in the later update. I think this is rather surprising.

@bowlofeggs bowlofeggs changed the title Bodhi's REST API sets severity to "unspecified" when updates are edited if the field is not present Bodhi's REST API sets all non specified fields to their defaults when updates are edited Mar 8, 2018
@cverna cverna added this to To do in vgolwala via automation Jun 27, 2018
@cverna cverna moved this from To do to In progress in vgolwala Jun 28, 2018
@cverna cverna moved this from In progress to In Review in vgolwala Jul 2, 2018
vgolwala automation moved this from In Review to Done Jul 9, 2018
cverna pushed a commit that referenced this issue Jul 9, 2018
fixes #2208

Signed-off-by: Vismay Golwala <vgolwala@redhat.com>
@bowlofeggs
Copy link
Contributor Author

The associated PR seems to fix the CLI so that it doesn't suffer from this issue, but the real issue is that the API should not alter fields that it was not given in edit calls. I'd like to fix that issue in a future X release, so I'm going to reopen it.

Thanks for fixing the CLI for it though, I think that'll really help with most real-world use cases that hit this problem ☺

@bowlofeggs bowlofeggs reopened this Jul 13, 2018
vgolwala automation moved this from Done to In progress Jul 13, 2018
@bowlofeggs bowlofeggs moved this from In progress to Done in vgolwala Jul 13, 2018
@bowlofeggs bowlofeggs added the Backwards incompatible The proposed change is backwards incompatible and should wait for the next major release label Jul 13, 2018
@bowlofeggs
Copy link
Contributor Author

A fix for the CLI is planned to be included in the upcoming 3.9.0 release: #2477.

@bowlofeggs
Copy link
Contributor Author

The CLI fix described above was released with 3.9.0.

@bowlofeggs
Copy link
Contributor Author

The real problem here is that Bodhi's REST API isn't very RESTy. It uses the same URL for creating and editing updates. To signal that you are editing an update, the user includes a key in the JSON with "edited" and the build's title. The REST way to do it would be for the user to POST to the update's URL (i.e., not the /updates/ endpoint, but /updates/FEDORA-2018-abcde).

By making this change, we can easily give a different schema to the edit API than the create API, which is difficult to do under the current model.

@bowlofeggs bowlofeggs changed the title Bodhi's REST API sets all non specified fields to their defaults when updates are edited Bodhi's REST API should separate the create and edit endpoints Dec 14, 2018
@cverna
Copy link
Contributor

cverna commented Dec 14, 2018

You could also make use of the PUT and PATCH HTTP method and follow the CRUD principle.

CREATE an update --> POST
UPDATE an update --> PUT
PARTIAL UPDATE of an update --> PATCH

@sebwoj
Copy link
Collaborator

sebwoj commented Jan 6, 2019

It looks like that "overrides" and "releases" apis are not RESTy as well.

@bowlofeggs bowlofeggs removed this from To do in Release Bodhi 4.0.0 Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues related to Bodhi's REST API Backwards incompatible The proposed change is backwards incompatible and should wait for the next major release High priority These issues are higher priority than normal
Projects
No open projects
vgolwala
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants