Files
copilotkit__copilotkit/sdk-python/copilotkit/intelligence.py
Maximiliano Korp 078ee356e0 fix(sdk-python): align ZIP bounds and the second-304 error code with the other SDKs
D4 - Python enforced only total archive bytes, entry count, and declared total
uncompressed bytes. It had no per-file byte bound, no compression-method
allowlist, and no artifact path-length bound, while TypeScript and C# enforce
`maxFileBytes` 10 MB, `maxFiles` 1000, stored/deflate only, and `maxPathLength`
512. Executed against the real SDKs on identical bundles at default limits,
Python accepted a 15 MB member, 3001 files, an LZMA member, and a 610-character
path that TypeScript rejected. All four are now refused with the same
`LEARNING_BLOB_INTEGRITY_FAILURE`/`validation` code and the peer messages. The
pre-existing `max_archive_entries` knob is kept for compatibility and both
bounds are enforced.

`_extract` also re-labelled every specific bound violation as "Invalid skill ZIP
archive", because `IntelligenceError` subclasses `RuntimeError` and its own
generic handler swallowed it. Typed errors are now re-raised first.

D5 - the second unconditional 304 raised `LEARNING_BLOB_INTEGRITY_FAILURE` in
the `validation` category, contradicting the shared golden fixture's
`expectations.secondUnconditional304Code` and both peer SDKs. It now raises
`IntelligenceCacheMissError`, which carries `LEARNING_SDK_CACHE_CORRUPT` in the
`internal` category, and the test asserts the fixture field rather than a
restated constant. `errors.*.invalidatesCache` is likewise asserted from the
fixture.

Collision and identity keys now route through the shared pinned folding helper
instead of `str.casefold()`, so Python cannot drift from TypeScript and C# on
code points added after the interpreter's Unicode version.
2026-07-24 16:33:54 -07:00

52 KiB