Skip to content

BUG-734 Fix OAuth tool deserialization crash and type mismatch#891

Open
aix-ahmet wants to merge 3 commits intodevelopmentfrom
bugfix/BUG-734-oauth-tool-deserialization
Open

BUG-734 Fix OAuth tool deserialization crash and type mismatch#891
aix-ahmet wants to merge 3 commits intodevelopmentfrom
bugfix/BUG-734-oauth-tool-deserialization

Conversation

@aix-ahmet
Copy link
Copy Markdown
Collaborator

@aix-ahmet aix-ahmet commented Apr 2, 2026

Summary

  • Fixes deserialization crash (AttributeError: 'str' object has no attribute 'items') that blocked all SDK usage for OAuth/Composio-backed integrations (Gmail, Slack, Jira, Google Drive)
  • Fixes as_tool() type mismatch where Tool instances emitted type: "model" instead of type: "tool", causing agent creation API validation errors
  • Adds error handling in Integration.connect() for failed connections (e.g., name collisions)

Changes

File Change
aixplain/v2/resource.py Wrap from_dict() in SearchResourceMixin with try/except to skip undeserializable items instead of crashing; wrap from_dict() in GetResourceMixin with a clear ResourceError
aixplain/v2/tool.py Override type to "tool" in Tool.as_tool()
aixplain/v2/mixins.py Expand ToolDict type literal to include sql, script, tool, integration
aixplain/v2/integration.py Validate response in connect() and raise ValueError on failure

Jira

BUG-734

Test plan

  • Tool.search(query="Gmail") no longer crashes when OAuth tools appear in results
  • Integration.get(composio_id) returns a clear ResourceError instead of cryptic AttributeError
  • Tool.as_tool() returns type: "tool" for OAuth tool instances
  • Agent creation with OAuth tools succeeds via Agent(..., tools=[tool]).save()
  • Existing non-OAuth flows (model tools, pipeline tools) are unaffected

Made with Cursor

- Add try/except around from_dict() in SearchResourceMixin to skip
  undeserializable OAuth tools instead of crashing the entire search
- Wrap from_dict() in GetResourceMixin with a clear ResourceError
  for better diagnostics when deserialization fails
- Fix Tool.as_tool() to emit type="tool" instead of inheriting "model"
  from the parent class, which caused agent API validation errors
- Expand ToolDict type literal to include all valid tool types
  (sql, script, tool, integration)
- Add error handling in Integration.connect() for failed connections

Made-with: Cursor
ActionMixin was missing the @DataClass decorator, so its actions_available
field was not included in __dataclass_fields__ of subclasses. This caused
from_dict() to silently ignore actionsAvailable from API responses, leaving
tool.actions empty and tool.run(action=...) broken.
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