-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Automatically fall back to create
when edit
fails for endpoints that support it
#3378
Comments
I've thought about this for other endpoints as well, but decided to not support it since I'm trying to match the API as much as possible. Though it would be helpful, It feels like functionality that should be supported in the API itself, or at least discussed in the API itself to have an upsert functionality as opposed to the wrapper. Definitely on the fence on this one. It could be handy |
I totally agree that it really should be in GitLab itself but I think that the chances of it getting in within 2+ years is slim :-(. I decided to ask for the feature when I found myself writing the code everywhere anyway. Maybe make it a toggle that defaults to Personally, I can't think of a time when you wouldn't want to fall back but edge cases are like that. |
Description
When using ProjectPushRules.edit() I discovered that, when nothing is originally set, GitLab will deny the edit with a 404 message.
There are two solutions:
ProjectPushRules.show()
to see if there is something there in the first place and choose which to call based on that (2 API calls)ProjectPushRules.edit()
, catch the error, and fall back onProjectPushRules.create()
with the exact same options.Proposal
Given that
edit()
andcreate()
have the exact same inputs, I would like to propose automatically falling back when possible so that the expected result occurs without the user needing to code around the edge cases.Checklist
The text was updated successfully, but these errors were encountered: