Skip to content

fix: handle missing 'type' key in nested object schemas#2861

Open
MaxwellCalkin wants to merge 1 commit intoComposioHQ:nextfrom
MaxwellCalkin:fix/dropbox-search-keyerror-2459
Open

fix: handle missing 'type' key in nested object schemas#2861
MaxwellCalkin wants to merge 1 commit intoComposioHQ:nextfrom
MaxwellCalkin:fix/dropbox-search-keyerror-2459

Conversation

@MaxwellCalkin
Copy link

Summary

Fixes #2459

When executing DROPBOX_SEARCH_FILE_OR_FOLDER with the optional options parameter, the SDK crashes with KeyError: 'type' before the API request is even sent. This happens because pydantic_model_from_param_schema() uses direct dictionary access (prop_info["type"], prop_info["title"]) on schema entries that may not have a top-level type key — nested object schemas can use anyOf, allOf, oneOf, or $ref instead.

Changes in python/composio/utils/shared.py

  • prop_info["type"]prop_info.get("type") — prevents KeyError on schemas without type
  • prop_info["title"]prop_info.get("title", prop_name) — falls back to property name when title is absent
  • FALLBACK_VALUES[prop_type]FALLBACK_VALUES.get(prop_type) — handles None prop_type gracefully
  • When prop_type is None (schema uses combiners instead of type), delegates to json_schema_to_pydantic_type() which already handles anyOf/allOf/oneOf correctly
  • Removed stale :raises KeyError from docstring since the function no longer raises it

Before

prop_type = prop_info["type"]           # KeyError if schema uses anyOf/allOf/$ref
prop_title = prop_info["title"]         # KeyError if title is absent
prop_default = prop_info.get("default", FALLBACK_VALUES[prop_type])  # KeyError if prop_type not in FALLBACK_VALUES

After

prop_type = prop_info.get("type")
prop_title = prop_info.get("title", prop_name).replace(" ", "")
prop_default = prop_info.get("default", FALLBACK_VALUES.get(prop_type))
if prop_type is not None and prop_type in PYDANTIC_TYPE_TO_PYTHON_TYPE and prop_type not in CONTAINER_TYPE:
    signature_prop_type = PYDANTIC_TYPE_TO_PYTHON_TYPE[prop_type]
elif prop_type is None:
    # Delegate to json_schema_to_pydantic_type which handles all combiners
    signature_prop_type = t.cast(t.Type, json_schema_to_pydantic_type(json_schema=prop_info))
else:
    signature_prop_type = pydantic_model_from_param_schema(prop_info)

This fix is generic — it handles all cases where a schema property lacks a type key, not just the Dropbox case.

Note: This PR was authored by Claude (AI), operated by @MaxwellCalkin.

…aram_schema

Schemas for nested objects may use anyOf/allOf/oneOf/$ref instead of a
top-level 'type' key. Direct dict access prop_info['type'] and
prop_info['title'] would raise KeyError in those cases (e.g. Dropbox
SEARCH_FILE_OR_FOLDER with an 'options' parameter).

Changes:
- prop_info['type']  -> prop_info.get('type')
- prop_info['title'] -> prop_info.get('title', prop_name)
- FALLBACK_VALUES[prop_type] -> FALLBACK_VALUES.get(prop_type)
- When prop_type is None, delegate to json_schema_to_pydantic_type()
  which already handles all combiner schemas correctly

Fixes ComposioHQ#2459
@MaxwellCalkin MaxwellCalkin requested a review from haxzie as a code owner March 8, 2026 05:50
@vercel
Copy link

vercel bot commented Mar 8, 2026

@MaxwellCalkin is attempting to deploy a commit to the Composio Team on Vercel.

A member of the Team first needs to authorize it.

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

[Bug]: Dropbox search crashes with KeyError: 'type' when options is provided

1 participant