Skip to content

Conversation

@thomaspdl
Copy link

@thomaspdl thomaspdl commented Jan 24, 2026

Overview

Adds Error Handling Corruption, a new procedural bug generation methodology that removes exception handling mechanisms to expose code to unhandled errors.

Changes

  • TryExceptRemover: Removes try/except blocks, exposing code to unhandled exceptions
  • AssertRemover: Removes assert statements and validation checks
  • RaiseRemover: Replaces raise statements with pass, causing silent failures

Files

  • New module: swesmith/bug_gen/error_handling/ (7 files)
  • Added constants: CodeProperty.HAS_TRY_EXCEPT, HAS_ASSERT, HAS_RAISE
  • Tests: All 10 unit tests passing

Usage

python -m swesmith.bug_gen.error_handling.generate --repo <repo> --seed <seed>

@thomaspdl thomaspdl changed the title Adding Remove Assert Functionnality to SWE smith Implement error_handling procedural modifiers to SWE smith Jan 24, 2026
@thomaspdl thomaspdl changed the title Implement error_handling procedural modifiers to SWE smith Adding error_handling procedural modifiers to SWE smith Jan 24, 2026
@john-b-yang
Copy link
Member

This is awesome, thank you so much @thomaspdl!

Just to confirm, based on the code, it looks like this is a Python specific method?

Would you mind providing a README.md that provides a summary of (1) what kind of bug is being created, (2) any constraints (e.g. only Python?), and (3) example usages?

Feel free to just plug these points into copilot / cursor / claude code or something, and double check that the descriptions are accurate.

If you're interested, would you open to writing a blog post describing this bug gen approach for https://www.swebench.com/blog.html?

@thomaspdl
Copy link
Author

thanks for the comments @john-b-yang!

Yes, this is a python only method.

Would you prefer me to add a separate README.md or edit the already existing one?

I will get on the blogpost this week :)

@john-b-yang
Copy link
Member

A separate README.md that sits under swesmith/bug_gen/error_handling would be absolutely amazing.

And woo! Very happy to hear you'd be open to a blog post! Just to give you a sense, here's where the content for posts lives under the SWE-bench website.

No rush at all, but when you get around to it, if you could (1) create the post as a markdown file, and include any assets you might want in a subfolder under the same directory, and then (2) make a PR to the SWE-bench website, that'd be awesome.

@thomaspdl
Copy link
Author

created the README.md
I'll put the blogpost in a separate PR if that's ok!

@john-b-yang
Copy link
Member

Awesome stuff @thomaspdl this is fantastic! Just took a look and I think the changes are fantastic, also just tagged @acrmp to sanity check as well.

And separate PR for blog post sounds great. Would you mind making the PR to this repository? Tysm in advance!

@john-b-yang john-b-yang requested a review from acrmp January 29, 2026 17:58
Copy link
Collaborator

@acrmp acrmp left a comment

Choose a reason for hiding this comment

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

Hi @thomaspdl, thanks for opening this PR. Excited for these changes!

❓ I had some issues getting these changes to run locally. Where you able to run the new error handling generate included in this PR locally?

❓ Did you consider adding the modifiers and having them available from the existing procedural modification command swesmith.bug_gen.procedural.generate?

Thanks!

Comment on lines +12 to +16
MODIFIERS_ERROR_HANDLING = [
TryExceptRemover,
AssertRemover,
RaiseRemover,
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these modifiers be instances of the classes rather than as the classes themselves?
I'm seeing an error when attempting to run swesmith.bug_gen.error_handling.generate:

TypeError: ProceduralModifier.can_change() missing 1 required positional argument: 'code_entity'

Comment on lines +84 to +87
# Error handling
HAS_TRY_EXCEPT = "has_try_except"
HAS_ASSERT = "has_assert"
HAS_RAISE = "has_raise"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the PR include the changes to set these code properties when the source files are parsed? I couldn't see these. I would expect them to be necessary to ensure that files are not filtered out by the conditions set on the removal modifiers (see swesmith/bug_gen/adapters/python.py).

(try/except, assert, raise statements).

Usage: python -m swesmith.bug_gen.error_handling.generate \
--repo <repo> \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is repo a positional argument rather than a flag? I think this might be an existing error copied over from the procedural generate.

@@ -0,0 +1,54 @@
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: the filename of this remover doesn't have the _removal.py suffix that assert_removal.py and raise_removal.py are using.

### Basic Usage
```bash
# Generate bugs for a repository
python -m swesmith.bug_gen.error_handling.generate "instagram__monkeytype.70c3acf6"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the case correct here for the included repo profile? Should this beInstagram__MonkeyType.70c3acf6?

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.

3 participants