mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-04 00:08:54 +00:00
fix: attaching a file without pandoc sometimes shows a raw error instead of "Pandoc is not installed" (#35065)
On a server without pandoc, attaching a file that needs it could show the raw library error, which tells the user to install pandoc themselves, instead of "Pandoc is not installed on the server". The raw error was saved first and replaced with the friendly message a moment later, and the chat often picked up the raw one in between. The friendly message is now saved right away, so the warning toast always shows it. Fixes #35064
This commit is contained in:
1 parent
bb51c01700
commit
7e5634d208
1 file changed
+6
-11
@@ -1894,11 +1894,12 @@ async def index_file(
|
||||
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
error = ERROR_MESSAGES.PANDOC_NOT_INSTALLED if 'No pandoc was found' in str(e) else str(e)
|
||||
# Fresh session for error status update.
|
||||
async with get_async_db() as session:
|
||||
await Files.update_file_data_by_id(
|
||||
file.id,
|
||||
{'status': 'failed', 'error': str(e)},
|
||||
{'status': 'failed', 'error': error},
|
||||
db=session,
|
||||
)
|
||||
# Clear the hash so the file can be re-uploaded after fixing the issue
|
||||
@@ -1917,16 +1918,10 @@ async def index_file(
|
||||
},
|
||||
)
|
||||
|
||||
if 'No pandoc was found' in str(e):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.PANDOC_NOT_INSTALLED,
|
||||
)
|
||||
else:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=str(e),
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=error,
|
||||
)
|
||||
|
||||
else:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND)
|
||||
|
||||
Reference in new issue
Block a user