Skip to content

fix(exceptions): record explicitly-supplied falsy details instead of dropping them - #281

Merged
himanshu231204 merged 2 commits into
OpenAgentHQ:mainfrom
Nitjsefnie-OSC:fix/exceptions-falsy-detail-drop
Aug 16, 2026
Merged

fix(exceptions): record explicitly-supplied falsy details instead of dropping them#281
himanshu231204 merged 2 commits into
OpenAgentHQ:mainfrom
Nitjsefnie-OSC:fix/exceptions-falsy-detail-drop

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

Description

Exception constructors guarded their detail recording with a truthiness test, so an explicitly-supplied empty string, 0, False, or [] was silently dropped from .details while only None should have meant "not supplied". This changes 21 such guards across the eight exception modules to test is not None.

The same defect was fixed for ValidationError in #279 (issue #68). Issue #280 asked whether ConfigurationError.field had it too — it does, and so do nineteen further guards in the same package, so this fixes the family rather than the one reported line.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test update
  • CI/CD update

Related Issues

Closes #280

How Has This Been Tested?

  • Unit tests pass (uv run pytest)
  • Linter passes (uv run ruff check .)
  • Type checker passes (uv run mypy openagent_eval/)
  • Manual testing performed

tests/unit/test_exceptions.py grew from 29 to 78 cases: one preservation case per touched module, non-string falsy values where the parameter type allows, and a negative case per module asserting that an unsupplied (None) parameter is still absent from .details — without that, "fix" could quietly degrade into "record everything".

The tests were confirmed to actually fail against unfixed sources: with the new tests in place and openagent_eval/exceptions/ restored to main, they fail; with the fix, 78 pass. They assert membership (assert "field" in exc.details) rather than indexing, so a missing key fails as an assertion rather than a KeyError.

Six of the guards take an original_error. Ordinary exception instances are truthy, so a test passing a plain ValueError would have passed against the old code too and proved nothing — those six are covered with an exception subclass whose __bool__ returns False, which is a real shape (an exception wrapping an empty collection inherits its __len__).

Full pytest tests/unit and the coverage gate ran green on a runner for this branch on Python 3.11 and 3.12.

The two unticked boxes are unticked deliberately rather than overlooked. ruff check . fails at main on pre-existing findings unrelated to this change, so it cannot pass here; ruff check limited to the changed files is clean. mypy openagent_eval/ is likewise not clean at main. Neither is a blocking gate in CI, and reporting an unrun or failing gate as passing seemed worse than saying so.

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation — no documented behaviour changes
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Guards deliberately left alone, in case it looks like an omission: base.py:26 and provider.py:42,44,46 format details that are already recorded rather than deciding what to record; provider.py:75, metric.py:59 and plugin.py:59 build message text, so changing them would alter user-visible wording; diagnosis.py:41, dataset.py:84, cli.py:90, cli.py:92 and metric.py:119 already test is not None.

Generated by Claude Opus 5 (brief, review), Kimi K3 (implementation), GPT-5.6-Luna (implementation), GPT-5.6-Sol (verification)

Nitjsefnie and others added 2 commits August 15, 2026 11:03
…dropping them (OpenAgentHQ#280)

Detail-recording guards used truthiness tests, so an explicitly passed
"", 0, False or [] was silently dropped from .details. Only None means
"not supplied". Switch all 21 guards in the exceptions package to
`is not None`, matching the fix that landed for OpenAgentHQ#68 in PR OpenAgentHQ#279.

Message-text construction guards and __str__ formatting are unchanged.

Co-Authored-By: Kimi K3 <noreply@kimi.com>
Co-Authored-By: GPT-5.6-Luna <noreply@openai.com>
@himanshu231204
himanshu231204 merged commit ecae086 into OpenAgentHQ:main Aug 16, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @Nitjsefnie!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

@himanshu231204

Copy link
Copy Markdown
Member

@Nitjsefnie Hi, also checkout this repo

https://github.com/OpenAgentHQ/localmem-mcp

https://github.com/OpenAgentHQ/localmem-mcp

waiting for your pr.

@Nitjsefnie

Copy link
Copy Markdown
Contributor Author

Thanks for the pointer — I’ll take a look at localmem-mcp and find a focused contribution.

@himanshu231204 himanshu231204 mentioned this pull request Aug 17, 2026
4 tasks
@Nitjsefnie
Nitjsefnie deleted the fix/exceptions-falsy-detail-drop branch August 19, 2026 14:49
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.

Same falsy-check pattern may affect ConfigurationError.field in config.py

2 participants