6 Commits

Author SHA1 Message Date
jkomyno 64fbc4ee03 fix(py): preserve nested provider argument presence 2026-08-10 22:14:21 +02:00
jkomyno 191d919eef fix(python): harden dynamic schema validation 2026-08-07 21:56:39 +05:30
jkomyno 3fef432dc0 fix: fail closed on invalid dynamic schemas 2026-08-07 21:03:08 +05:30
jkomyno bbeacac653 fix(python): preserve and police dynamic object content in schema conversion
`json_schema_to_model` and `json_schema_to_pydantic_type` now share one
compiled object policy, so provider-facing Pydantic models stop silently
discarding valid free-form arguments and stop ignoring `patternProperties` and
explicit `additionalProperties` controls. Accepted dynamic keys are written back
into `__pydantic_extra__`, which is what `LangchainProvider.wrap_tool` re-reads
with `getattr`.

Acceptance and rejection are asserted from the shared cross-SDK corpus, so the
Python entry points cannot diverge from the TypeScript converters.
2026-08-06 20:40:59 +05:30
manjunath bhaskar 8cb290be35 fix(schema_converter): allOf containing a false member must reject every value (#3921)
### Summary

Preserves JSON Schema boolean-schema semantics throughout the Python
schema converter:

- an unsatisfiable `allOf` now propagates through nested combiners
instead of being dropped;
- impossible array items, object properties, and local definition
references remain rejecting;
- composed impossible schemas use a Pydantic type that rejects every
value, including JSON `null`;
- the existing `json_schema_to_pydantic_type(False) is None`
compatibility behavior remains unchanged.

### Problem

The original fix handled only a literal `false` directly inside one
`allOf`. Recursive filtering still interpreted the same `None` value as
both "discard this union branch" and "the whole schema is impossible."
That widened nested `allOf` schemas to `str`, removed impossible
properties/items/definitions, and allowed JSON `null` because Pydantic
treats a bare `None` annotation as `NoneType`.

### Fix

- Add a private unsatisfiable marker with Pydantic core- and JSON-schema
hooks.
- Drop that marker only from `anyOf`/`oneOf`; propagate it through
`allOf`.
- Preserve rejecting semantics for nested object properties, array
items, and local `$defs`/`definitions` references.
- Emit `{"not": {}}` from the rejecting Pydantic type.
- Correct the related empty-`allOf` and all-false-`anyOf` expectations.

### Testing

- `uv run pytest tests/test_schema_converter.py
tests/test_schema_parser.py -q` - 106 passed
- `uv run pytest -m schema -q` - 71 passed
- `make tst` - 928 passed
- `make chk` - Ruff and mypy passed across core, providers, tests, and
scripts

Regression coverage includes direct and nested `allOf`, JSON `null`,
empty arrays with impossible items, optional and required impossible
properties, local definition references, generated JSON Schema, and
shared model consumers.

### Note

#3876 adds coverage for the same function's `anyOf` handling but does
not change this `allOf` propagation path.

---------

Co-authored-by: jkomyno <alberto@composio.dev>
2026-07-28 14:15:49 +05:30
eeshsaxena d94aa32a41 test: add unit tests for the schema_converter boolean-schema filter (#3876)
## Description

`composio.utils.schema_converter._filter_boolean_schemas` pre-processes
JSON
Schemas before handing them to `json-schema-to-pydantic`, which doesn't
support boolean schemas (draft-06+ allows `true`/`false` as schemas). It
replaces `true` with `{}`, drops `false`, and recurses through combiner
arrays (`anyOf`/`allOf`/`oneOf`), `properties`, `items` and `$defs`. It
had no
test coverage.

This adds `python/tests/test_schema_converter.py` covering:

- `True` -> `{}` and `False` -> `None`
- non-schema values passing through unchanged
- lists dropping `False` entries, and an all-`False` list becoming
`None`
- combiner arrays dropping `False` entries, and the whole combiner being
  removed when every entry is `False`
- a `False` property being dropped while siblings are kept
- plain keys being preserved

No source changes.

## Verification

`pytest python/tests/test_schema_converter.py` - 9 passed. `ruff check`
/
`ruff format` clean.

Co-authored-by: jkomyno <alberto@composio.dev>
2026-07-28 13:18:40 +05:30