expectedparrot / edsl

Design, conduct and analyze results of AI-powered surveys and experiments. Simulate social science and market research with large numbers of AI agents and LLMs.
https://docs.expectedparrot.com
MIT License
192 stars 19 forks source link

Incorrect error message shown when object uuid is not passed to Coop client patch() method #832

Open rbyh opened 3 months ago

rbyh commented 3 months ago

Notebook showing this error: https://chick.expectedparrot.com/content/6cfe0ebb-15a1-449b-8c21-7a999945d327

No issues posting objects to Coop directly or using Coop client object. No issues using the patch() method directly or using Coop client object. When I do not pass the object uuid to the object's patch() method I get a clear correct error message that the uuid is missing. Problem: When I do not pass the object uuid to the Coop client's patch() method I get an error message that I am missing an API key.

To reproduce:

from edsl import QuestionMultipleChoice, Coop

q = QuestionMultipleChoice(
    question_name = "primary_color",
    question_text = "What is your favorite primary color?",
    question_options = ["Red", "Yellow", "Blue"]
)

q.push()

c = Coop()

c.patch(q, visibility="public") # This should generate an error message that I forgot the uuid
apostolosfilippas commented 3 months ago

@rbyh I don't get an API key error, I'm getting:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/apostolosfilippas/edsl/edsl/coop/coop.py", line 260, in patch
    "visibility": visibility,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apostolosfilippas/edsl/edsl/coop/coop.py", line 87, in _resolve_server_response
    raise Exception(message)
Exception: [{'type': 'uuid_parsing', 'loc': ['query', 'uuid'], 'msg': 'Input should be a valid UUID, invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `┏` at 1', 'input': '┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓\n┃ Question Name ┃ Question Type   ┃ Question Text                        ┃ Options           ┃\n┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩\n│ primary_color │ multiple_choice │ What is your favorite primary color? │ Red, Yellow, Blue │\n└───────────────┴─────────────────┴──────────────────────────────────────┴───────────────────┘\n', 'ctx': {'error': 'invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `┏` at 1'}, 'url': 'https://errors.pydantic.dev/2.6/v/uuid_parsing'}

Which is more correct (not a very informative error though)

rbyh commented 3 months ago

Ah yes - I was distracted by the line about the EP API key before it. This is what I'm getting too - I think an instruction with example would be more helpful?

image