You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 is null and not allowed, return a 400 Bad Request status code with a clear error message.
Alternatively, modify the update logic to ignore null values for fields where null 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 the openAiHistory field is null and cannot be processed.
Alternatively, the API should ignore the null value for openAiHistory and update the workspace with the provided valid fields, returning a 200 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:
In the interim, openAiHistory should be any non-zero number - 20 is the default. This is the amount of chat history included in a chat response.
Wrt this issue, each writable field should have some conditional form of validation - which was omitted historically to prevent non-writable fields from being edited via the Workspace.update method.
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:the endpoint incorrectly returns a
200
status code with the following message:The response indicates an error in the
prisma.workspaces.update()
invocation due to theopenAiHistory
field beingnull
, 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:
openAiHistory
isnull
and not allowed, return a400 Bad Request
status code with a clear error message.null
values for fields wherenull
is not allowed, and proceed with updating the other valid fields.Are there known steps to reproduce?
Expected Behavior:
400 Bad Request
) if theopenAiHistory
field isnull
and cannot be processed.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:
/v1/workspace/{slug}/update
with the following payload:Actual Response:
200 OK
The text was updated successfully, but these errors were encountered: