Repository navigation
Description
** Please make sure you read the contribution guide and file the issues in the right place. **
Describe the bug
The v0→v1 session migration tool's restricted unpickler (added in 9db48ce9, "fix(migration): restrict unpickling of v0 actions blobs") blocks builtins.getattr, and on Python 3.11 — specifically an environment with the full test extras installed, where crewai[tools] applies per the pyproject marker python_version>='3.11' and python_version<'3.12' — the pickled EventActions graph contains a getattr global. The unpickler rejects it, _safe_unpickle_actions logs a WARNING and falls back to empty actions, and migrated events silently lose requested_auth_configs and compaction.
Observable today as a deterministic unit-test failure on the py311 tox environment:
FAILED tests/unittests/sessions/migration/test_migration.py::test_migrate_from_sqlalchemy_pickle_preserves_nested_safe_actions_pickle
AssertionError: assert 'fc-auth' in {}
with this in the captured log:
WARNING ... Failed to unpickle actions for event event1: Blocked global during migration unpickle: builtins.getattr
To Reproduce
Steps to reproduce (repo at current main):
uv venv --python "python3.11" .venv && source .venv/bin/activate && uv sync --all-extraspytest "tests/unittests/sessions/migration/test_migration.py::test_migrate_from_sqlalchemy_pickle_preserves_nested_safe_actions_pickle"- Test fails as above. The same test passes on py310, py312, py313, and py314 tox environments (
toxrun:py310 OK, py311 FAIL, py312 OK, py313 OK, py314 OK).
Ruling out version skew: pydantic (2.12.5), fastapi (0.141.1), and google-genai (2.17.0) are identical across the py310/py311/py312 environments — the only material difference in the failing environment is the presence of crewai and its transitive dependencies, which only install on 3.11. A plausible mechanism is a pydantic plugin registered via entry points by one of those transitive dependencies altering how pydantic model instances pickle (introducing a getattr reduction), but I have not bisected the exact package.
Expected behavior
Either the migration unpickler accepts the pickle streams that pydantic models actually produce in every supported environment (so nested EventActions content survives migration), or — if builtins.getattr must stay blocked for hardening reasons — the migration should not silently degrade to {} for blobs a supported environment wrote. Silent data loss during migration is the worst outcome of the current behavior; the test correctly catches it.
Desktop:
- OS: macOS (Darwin 24.6.0)
- Python version: 3.11 (failing); 3.10/3.12/3.13/3.14 (passing)
- ADK version: current
main(c5672030)
Additional context
- Found while running the full
toxmatrix to prepare PR fix: report root_agent type mismatch instead of 'No root_agent found' #6635 (fix for AgentLoader discards its own diagnosis: type mismatch onroot_agentis logged at WARNING, then reported as "No root_agent found" #6606); that diff touches onlycli/utils/agent_loader.py, and this failure reproduces identically on unmodifiedmain. - Related hardening work: Security: Unsafe pickle.loads() in v0 schema runtime path and migration tool #5634 (unsafe
pickle.loads()in v0 schema paths). - Relevant code:
_ALLOWED_PICKLE_GLOBALSand the blocked-global raise insrc/google/adk/sessions/migration/migrate_from_sqlalchemy_pickle.py(allowlist at line ~41, rejection at line ~113-116).
🤖 Generated with Claude Code
Activity
vup903 commentedon Aug 8, 2026
Hi, I’m a Python contributor focusing on agent runtime reliability. I reproduced this on Windows 11 with CPython 3.11 and traced the pickle payload directly.
The trigger is not a Pydantic plugin: CPython 3.11 serializes enum members such as
SecuritySchemeType.httpthroughbuiltins.getattr(EnumClass, member_name), while newer Python versions use the enum value constructor.I have a narrow fix in progress that substitutes a restricted enum-member resolver instead of allowlisting arbitrary
getattr. It only accepts already-allowlisted enum classes and names present in__members__; non-enum and dunder lookups remain blocked. I’ve also added cross-version regression coverage and negative security tests.Would this direction be acceptable, and could I be assigned to the issue?
llalitkumarrr commentedon Aug 12, 2026
Hello @loponly,
We tried to reproduce this issue using the current main (
a56f6e13) but we were unable to reproduce it on our end. Could you please test this on your end and share your observations?a2105z commentedon Aug 13, 2026
I tried to reproduce this on current
main(18903cad) as well.Environment
uv sync --all-extras(crewai 1.6.1 is installed)Result
Could not reproduce the failure:
UV_PROJECT_ENVIRONMENT=.venv-py311 uv run --python 3.11 pytest \ tests/unittests/sessions/migration/test_migration.py::test_migrate_from_sqlalchemy_pickle_preserves_nested_safe_actions_pickle -vv # 1 passedI also pickled the same nested
EventActions(AuthConfig(HTTPBearer()), …)graph and inspected the stream: on this 3.11.15 build,SecuritySchemeType.httppickles viaSTACK_GLOBAL+REDUCE(nobuiltins.getattr), and_restricted_pickle_loadssucceeds withfc-authpreserved.That lines up with @llalitkumarrr’s non-repro on
a56f6e13.Notes / ask
getattrtheory is plausible for some 3.11 pickle layouts, but I’m not seeing that opcode in the current dependency set.@loponly if you still hit this, could you share:
python -Vpatch (e.g. 3.11.x),pip show pydantic fastapi google-genai crewai,actionspickle blob?Happy to help land a safe enum-member resolver if we can get a failing payload; I’ve opened a local branch ready for that once we have a deterministic repro.
llalitkumarrr commentedon Sep 10, 2026
Closing this issue since this is not reproducible.