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

PATCH method required for /api/admin/context/{contextField} #8934

Open
preetiakrohilla opened this issue Dec 9, 2024 · 1 comment
Open

Comments

@preetiakrohilla
Copy link

Describe the feature request

Hi Team,

We have a use case where we are trying to update the Unleash UserId context field in parallel. Here are the steps we follow:

We are using REST APIs to update the context field.

  1. To get the current list of legal values for a given userId context field, use the following GET request:

curl --header "Authorization: xxxxxxxxxxxxxxxxxx" --header "Content-Type: application/json" http://localhost:4242/api/admin/context/userId
Sample response:
{
"name": "userId",
"description": "Allows you to constrain on userId",
"stickiness": false,
"sortOrder": 1,
"legalValues": [
{
"value": "aeb27c26-8952-434c-a724-e86fbd124e15",
"description": "test1"
}
],
"createdAt": "2023-10-29T13:25:26.078Z"
}

  1. Add the new userId value to the list of legalValues received in the response from step Agree on a license #1

For example, you may want to add a new user ID like this:
{
"value": "6880e05c-df57-4a06-af65-418e57754d19",
"description": "test2"
}

  1. Use a PUT request to update the userId context field with the modified legalValues list:

curl --request PUT 'http://localhost:4242/api/admin/context/userId'
--header 'Authorization: xxxxxxxxxxxxxx'
--header 'Content-Type: application/json'
--data-raw '{
"name": "userId",
"description": "Allows you to constrain on userId",
"legalValues": [
{
"value": "aeb27c26-8952-434c-a724-e86fbd124e15",
"description": "test1"
},
{
"value": "6880e05c-df57-4a06-af65-418e57754d19",
"description": "test2"
}
],
"stickiness": false
}'

Potential Issue:
Two concurrent requests might lead to data overwriting on the server, as both requests may fetch the same state in step #1 and update the context field simultaneously. This can result in the loss of changes made by one request when the other request is processed later.

Background

No response

Solution suggestions

Introduce Patch Method for Unleash Rest API /api/admin/context/{contextField}

@FredrikOseberg
Copy link
Contributor

@preetiakrohilla

Hi.

I can see the use-case for this functionality, however we have other priorities that are more pressing right now. If you would like to contribute this functionality we'd be happy to take a look at it, otherwise we'll have to revisit this in the future.

@FredrikOseberg FredrikOseberg moved this from New to Investigating in Issues and PRs Dec 10, 2024
@FredrikOseberg FredrikOseberg moved this from Investigating to For later in Issues and PRs Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For later
Development

No branches or pull requests

2 participants