Skip to content

Conversation

@sscargal
Copy link
Contributor

@sscargal sscargal commented Jan 8, 2026

Purpose of the change

This addresses the 5 CodeQL "Information exposure through an exception" issues.

Description

GitHub CodeQL highlighted some potential security issues relating to the examples/v1/writing_assistant/writing_assistant_server.py file:

Screenshot 2026-01-08 at 1 21 55 PM Screenshot 2026-01-08 at 1 31 01 PM

The resolution is to remove all occurrences of {e!s} and replace it with a more human-friendly message. Rather than generic messages, we can still include useful information from the exception without displaying the full data or stack by introducing a new format_error_response() function to process the exception and return relevant information only.

Fixes/Closes

Fixes CodeQL issues 39, 40, 41, 42, & 43.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Security (improves security without changing functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • Manual verification (list step-by-step instructions)

Checklist

  • I have signed the commit(s) within this pull request
  • My code follows the style guidelines of this project (See STYLE_GUIDE.md)
  • I have performed a self-review of my own code
  • I have commented my code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • Confirmed all checks passed
  • Contributor has signed the commit(s)
  • Reviewed the code
  • Run, Tested, and Verified the change(s) work as expected

Screenshots/Gifs

See above

Further comments

None

Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses 5 CodeQL security vulnerabilities related to information exposure through exception messages. The changes prevent potentially sensitive exception details from being leaked to API consumers by replacing direct exception string interpolation with a centralized error formatting function that returns sanitized, user-friendly error messages.

Key Changes:

  • Introduced a format_error_response() helper function to standardize error handling
  • Replaced direct exception exposure in all exception handlers with calls to the new helper
  • Maintained appropriate logging while preventing information leakage to end users

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com>
@sscargal sscargal merged commit a8fccc7 into MemMachine:main Jan 9, 2026
38 checks passed
@sscargal sscargal deleted the bugfix/writing-assistant branch January 9, 2026 20:10
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.

1 participant