Open
Description
How are you running AnythingLLM?
Docker (remote machine)
What happened?
When calling the endpoint /v1/workspace/{slug}/update
with a POST request and the following payload:
{
"name": "Updated Workspace Name",
"openAiHistory": null
}
the endpoint incorrectly returns a 200
status code with the following message:
{
"workspace": null,
"message": "\nInvalid `prisma.workspaces.update()` invocation:\n\n{\n where: {\n id: 17\n },\n data: {\n name: \"basssis Updated Workspace Name\",\n+ openAiHistory: Int\n }\n}\n\nArgument `openAiHistory` must not be null."
}
The response indicates an error in the prisma.workspaces.update()
invocation due to the openAiHistory
field being null
, which is not allowed.
Additional Information:
This issue leads to confusion as the status code 200 OK
suggests that the operation was successful, while the message indicates an error. Proper error handling is required to ensure the API behaves as expected.
Suggested Fix:
- Validate the payload before attempting to update the workspace. If
openAiHistory
isnull
and not allowed, return a400 Bad Request
status code with a clear error message. - Alternatively, modify the update logic to ignore
null
values for fields wherenull
is not allowed, and proceed with updating the other valid fields.
Are there known steps to reproduce?
Expected Behavior:
- The endpoint should return an appropriate error code (e.g.,
400 Bad Request
) if theopenAiHistory
field isnull
and cannot be processed. - Alternatively, the API should ignore the
null
value foropenAiHistory
and update the workspace with the provided valid fields, returning a200
status code only if the operation is successful.
Steps to Reproduce:
- Deploy the API using Docker.
- Send a POST request to
/v1/workspace/{slug}/update
with the following payload:{ "name": "Updated Workspace Name", "openAiHistory": null }
- Observe the response status code and message.
Actual Response:
- Status Code:
200 OK
- Response Body:
{ "workspace": null, "message": "\nInvalid `prisma.workspaces.update()` invocation:\n\n{\n where: {\n id: 17\n },\n data: {\n name: \"basssis Updated Workspace Name\",\n+ openAiHistory: Int\n }\n}\n\nArgument `openAiHistory` must not be null." }