Skip to content

feat(exceptions): standardize provider error __str__ format#167

Merged
himanshu231204 merged 4 commits into
OpenAgentHQ:mainfrom
lesbass:fix/standardize-provider-errors
Jul 17, 2026
Merged

feat(exceptions): standardize provider error __str__ format#167
himanshu231204 merged 4 commits into
OpenAgentHQ:mainfrom
lesbass:fix/standardize-provider-errors

Conversation

@lesbass

@lesbass lesbass commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Closes #113

Summary

Adds error_type class attribute and __str__ override to ProviderError and its subclasses, producing a consistent [provider] error_type: message format across all LLM providers.

Changes

  • openagent_eval/exceptions/provider.py: Added error_type class attribute and __str__ override to ProviderError, ProviderNotFoundError, ProviderConnectionError, and ProviderExecutionError
  • tests/unit/test_exceptions.py: Updated tests for new standardized format, added format tests with provider name

Format

Error class error_type Example output
ProviderError "Provider Error" [openai] Provider Error: API key not found
ProviderNotFoundError "Provider Not Found" [my_provider] Provider Not Found: Provider not found: my_provider
ProviderConnectionError "Connection Error" [gemini] Connection Error: Failed to connect
ProviderExecutionError "Execution Error" [anthropic] Execution Error: API call failed

When provider_name is None, the [...] prefix is omitted.

Verification

  • Unit tests: 26/26 passed (test_exceptions.py)
  • Ruff: clean on changed files
  • Integration tests: not run (missing loguru dependency, pre-existing)

lesbass and others added 2 commits July 16, 2026 06:06
Add error_type class attribute and __str__ override to ProviderError
and subclasses, producing consistent [provider] type: message output
across all LLM providers.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@himanshu231204

Copy link
Copy Markdown
Member
image

Thanks for the PR! The CI tests are failing across all supported Python versions. Please check the workflow logs, fix the failures, and update the PR. 👍

The __str__ override dropped self.details from the output, which broke
existing tests that match on details keywords (e.g., 'available_embedders',
'available_retrievers').

Include non-provider_name details in the standardized format, matching
the base OpenAgentEvalError behavior.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@lesbass

lesbass commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I found the issue — the __str__ override was dropping self.details from the output, which broke pytest.raises(match=...) patterns that match on detail keys (e.g., available_embedders, available_retrievers).

Fixed in the latest commit: the __str__ now includes non-provider_name details in the standardized format, matching the base OpenAgentEvalError behavior. The provider_name key is filtered out (already shown in the [provider] prefix).

[nope] Provider Not Found: Provider not found: nope (available_embedders=mock, sentence_transformers)
[gemini] Connection Error: Failed to connect (original_error=Connection failed)
[anthropic] Execution Error: API call failed (original_error=Execution failed)

All unit tests pass locally. CI should be green now.

@lesbass

lesbass commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

The __str__ fix has been pushed (commit 7e4510a). The issue was that __str__ wasn't including self.details, which caused pytest.raises(match=...) patterns matching on detail keys (available_embedders, available_retrievers) to fail.

Local verification (Python 3.13):

  • All 26 exception tests pass
  • The two previously failing tests (test_unknown_embedder, test_unknown_retriever) now pass
  • All other tests that were passing before still pass

CI status: The latest CI run needs maintainer approval (first-time contributor policy). Could you approve the workflow? The previous run was at HEAD before the fix commit.

Pre-existing unrelated failures in CI (missing optional openai/tiktoken/pypdf dependencies and one flaky semantic similarity test) are unchanged by this PR.

@himanshu231204
himanshu231204 merged commit 35b68d1 into OpenAgentHQ:main Jul 17, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @lesbass!

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! ❤️

🌟 This is your first merged contribution to this repository.
Welcome to the OpenAgentHQ contributors family!

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.

Standardize error messages across all LLM providers for consistency

2 participants