LibreChat
LibreChat copied to clipboard
[Bug]: Prompt Library does not update the selected prompt after using filters
What happened?
If you select a prompt and use the filter and remove the filter sometimes even there are no filters applied there is no prompt found. And if this happens you can not update the selected prompt, you get the error "There was an error updating the prompt".
As I investigated, the problem is caused by the
const validatedPageNumber = Math.max(parseInt(pageNumber, 10), 1);
from Prompt.js line 152, pageNumber is being undefined.
const skip = Number.isNaN((validatedPageNumber - 1) * validatedPageSize) ? 0 : (validatedPageNumber - 1) * validatedPageSize;
I fixed the problem by checking if the skip value isNan or not but probably it is not the actual fix for this problem. Probably its should be fixed in the frontend.
Steps to Reproduce
- Go to Prompts page.
- Select a prompt.
- Use the filter while the prompt is selected.
- Update the prompt while the prompts are filtered.
- Remove the filters. After removing it can not found any prompts somehow.
- Try to update the selected prompt again.
What browsers are you seeing the problem on?
Chrome
Relevant log output
invalid argument to $skip stage: Expected an integer, but found NaN in: $skip: nan.0
Screenshots
https://github.com/danny-avila/LibreChat/assets/44726724/af2b61d1-1b4c-47f8-a2b3-949385c82468
Code of Conduct
- [X] I agree to follow this project's Code of Conduct