Skip to content

Handle None input in sanitize function#119

Open
MehdiLotfian wants to merge 1 commit intobigcode-project:mainfrom
MehdiLotfian:main
Open

Handle None input in sanitize function#119
MehdiLotfian wants to merge 1 commit intobigcode-project:mainfrom
MehdiLotfian:main

Conversation

@MehdiLotfian
Copy link

LLMs fails to generate answers for some tasks. the added if block prevent error in running the generation code in these cases.

Copilot AI review requested due to automatic review settings March 17, 2026 10:57
Copy link

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

Adds a guard in the tree-sitter–based sanitizer to tolerate None inputs, avoiding runtime errors during code post-processing of LLM outputs.

Changes:

  • Return an empty string early when sanitize() receives None.
  • Keep existing sanitize/extract fallback behavior unchanged for non-None inputs.

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

You can also share your feedback on Copilot code review. Take the survey.

@@ -180,6 +180,8 @@ def extract_target_code_or_empty(code: str, entrypoint: Optional[str] = None) ->


def sanitize(code: str, entrypoint: Optional[str] = None) -> str:
Comment on lines 182 to +183
def sanitize(code: str, entrypoint: Optional[str] = None) -> str:
if code is None:
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