Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@JisanAR03
Copy link
Contributor

This PR introduces improved error handling and logging to the chatbot_conversation API endpoint. The key changes include:

  • Error Logging: If an error occurs, the question is logged in the ChatBotLog table with a corresponding error message.
  • Validation Checks: Enhanced validation for API keys and questions, with appropriate error responses.
  • Exception Handling: Wrapped critical code sections in try-except blocks to ensure any errors are caught and logged.

These changes ensure that any issues are properly logged, aiding in debugging and improving the overall reliability of the chatbot.

Changes:

  • Added error logging for invalid API keys, invalid questions, and vector store not found.
  • Implemented try-except blocks to catch and log exceptions during the conversation processing.
  • Maintained existing functionality for handling the "exit" command and logging successful conversations.

These enhancements help in better monitoring and maintaining the chatbot application.

@DonnieBLT sir , can you please confirm this one as solution of #2516

@JisanAR03 JisanAR03 mentioned this pull request Aug 2, 2024
except Exception as e:
error_message = f"Error: {str(e)}"
ChatBotLog.objects.create(question=question, answer=error_message)
return Response({"error": error_message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

Check warning

Code scanning / CodeQL

Information exposure through an exception

[Stack trace information](1) flows to this location and may be exposed to an external user.
except Exception as e:
error_message = f"Error: {str(e)}"
ChatBotLog.objects.create(question=request.data.get("question", ""), answer=error_message)
return Response({"error": error_message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

Check warning

Code scanning / CodeQL

Information exposure through an exception

[Stack trace information](1) flows to this location and may be exposed to an external user.
@DonnieBLT
Copy link
Collaborator

Can you please fix this? Information exposure through an exception

@DonnieBLT DonnieBLT enabled auto-merge (squash) August 2, 2024 14:47
@DonnieBLT DonnieBLT merged commit 8085ce3 into OWASP-BLT:main Aug 2, 2024
@JisanAR03 JisanAR03 deleted the fix_2516 branch August 2, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants