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

Unable to update variable in UI or using python sdk even when using overwrite=True - Error 'A variable with the name "the_answer" already exists.' #13291

Closed
4 tasks done
taylor-curran opened this issue May 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@taylor-curran
Copy link
Contributor

taylor-curran commented May 9, 2024

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

Updating existing variables appears to broken both in the UI and via the python sdk.
image

I use overwrite=True but still see the error "A variable with the name 'the_answer' already exists."

# update a variable
answer = Variable.set(name="the_answer", value="43", overwrite=True)
print(answer.value)

I tried out the example from Prefect's release notes v2.17.0 and see this error.

Reproduction

First run:

from prefect.variables import Variable

# set a variable
variable = Variable.set(name="the_answer", value="42")

Then:

from prefect.variables import Variable

# get a variable
answer = Variable.get('the_answer')
print(answer.value)
# 42

And finally run:

from prefect.variables import Variable

# update a variable
answer = Variable.set(name="the_answer", value="43", overwrite=True)
print(answer.value)
#43

Error

Traceback (most recent call last):
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/odsc/with_pref/vars.py", line 12, in <module>
    answer = Variable.set(name="the_answer", value="43", overwrite=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 300, in coroutine_wrapper
    return call()
           ^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 432, in __call__
    return self.result()
           ^^^^^^^^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 318, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 179, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 389, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/variables.py", line 58, in set
    await client.update_variable(variable=var)
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/client/orchestration.py", line 2962, in update_variable
    await self._client.patch(
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1966, in patch
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/client/base.py", line 356, in send
    response.raise_for_status()
  File "/Users/taylorcurran/Documents/kevin/prefect-demos/.venv/lib/python3.12/site-packages/prefect/client/base.py", line 169, in raise_for_status
    raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__
prefect.exceptions.PrefectHTTPStatusError: Client error '409 Conflict' for url 'https://api.prefect.cloud/api/accounts/0ff44498-d380-4d7b-bd68-9b52da03823f/workspaces/e30d4419-8433-4a8f-815d-06c4b43ab225/variables/name/the_answer'
Response: {'detail': "A variable with the name 'the_answer' already exists."}
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409

Versions

Version:             2.18.3
API version:         0.8.4
Python version:      3.12.2
Git commit:          c449aee8
Built:               Thu, May 2, 2024 5:47 PM
OS/Arch:             darwin/arm64
Profile:             se-demos
Server type:         cloud

Additional context

No response

@taylor-curran taylor-curran added bug Something isn't working needs:triage Needs feedback from the Prefect product team labels May 9, 2024
@taylor-curran taylor-curran changed the title Unable to update variables - I use overwrite=True but still see the error "A variable with the name 'the_answer' already exists." Unable to update variable using overwrite=True - Error 'A variable with the name "the_answer" already exists.' May 9, 2024
@mthatt
Copy link

mthatt commented May 9, 2024

Had a call with a customer experiencing the same issue earlier today, and I'm able to reproduce it on my end as well. The same error shows up when trying to edit a variable in the UI.

@taylor-curran
Copy link
Contributor Author

taylor-curran commented May 9, 2024

Thank @mthatt I can confirm its not working in the UI -- I'll edit the issue above to reflect this.
image

@taylor-curran taylor-curran changed the title Unable to update variable using overwrite=True - Error 'A variable with the name "the_answer" already exists.' Unable to update variable in UI or using python sdk even when using overwrite=True - Error 'A variable with the name "the_answer" already exists.' May 9, 2024
@zhen0 zhen0 removed the needs:triage Needs feedback from the Prefect product team label May 20, 2024
@zhen0
Copy link
Member

zhen0 commented May 20, 2024

@taylor-curran - I believe this has been fixed (and I can no longer recreate so I am closing this issue.) Please let me know if I am missing something!

@zhen0 zhen0 closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants