Open theomeuh opened 2 months ago
Thanks @theomeuh we'll look into it, we have somewhat related work we're planning to take on soon, and I included this as part of that backlog, we'll keep you posted on this ticket.
Hi @theomeuh,
Thank you for bringing up this issue. We’ve reviewed your concerns and I’d like to provide some clarification and updates.
You’re correct in pointing out that the behavior of the endpoint can be confusing, especially regarding how it handles PUT requests. While the API documentation indicates that unspecified fields will remain untouched (which would align more with PATCH behavior), the endpoint currently requires name
and constraints
to be present. Other fields should be left untouched, however there's also an edge case for the project
property, where it is reset to null
if not present.
https://github.com/Unleash/unleash/pull/8085 doesn’t really fix the issue, but at least it includes the request body schema, which is the same as the POST endpoint.
In the meantime, for your specific use case of updating only the constraints, a potential workaround would be to include the name
to avoid the 400 error, even if you’re not intending to change it. Also keep in mind that you'll need to provide the project
in case they are project-specific segments, as mentioned in the edge case above.
We acknowledge that the current behavior is far from great, and we'll take this into consideration when we discuss the future of our API and respective OpenAPI spec.
Discussed in https://github.com/orgs/Unleash/discussions/7980
Current behavior
A PUT requests on
api/admin/segments/:id
with in body a json containing only the keyconstraints
returns a 400, saying the fieldname
is requiredExpected behavior
A PUT requests on
api/admin/segments/:id
with in body a json containing only the keyconstraints
must return a 200 (and update theconstraints
field)