LibreChat icon indicating copy to clipboard operation
LibreChat copied to clipboard

[Bug]: Prompt Library does not update the selected prompt after using filters

Open meroo36 opened this issue 7 months ago • 0 comments

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

  1. Go to Prompts page.
  2. Select a prompt.
  3. Use the filter while the prompt is selected.
  4. Update the prompt while the prompts are filtered.
  5. Remove the filters. After removing it can not found any prompts somehow.
  6. 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

meroo36 avatar Jul 08 '24 11:07 meroo36