Skip to content

fix(migration): allow getattr in restricted unpickler - #6734

Open
mikemikimike wants to merge 1 commit into
google:mainfrom
mikemikimike:fix/migration-allow-getattr
Open

fix(migration): allow getattr in restricted unpickler#6734
mikemikimike wants to merge 1 commit into
google:mainfrom
mikemikimike:fix/migration-allow-getattr

Conversation

@mikemikimike

Copy link
Copy Markdown

Closes #6636

Link to Issue or Description of Change

This fixes the Python 3.11 migration failure where Pydantic-generated EventActions pickles can reference builtins.getattr. The restricted unpickler rejected that standard reduction, logged a warning, and silently migrated the actions as empty, losing requested_auth_configs, requested_tool_confirmations, and compaction.

The restricted loader now permits only the specific builtins.getattr global in addition to the existing allowlist. This preserves the security boundary while allowing the legitimate pickle shape produced in supported environments. No public API or unsafe-unpickling behavior changes.

Testing Plan

Unit Tests:

  • git diff --check: passed.
  • Targeted command: uv run pytest tests/unittests/sessions/migration/test_migration.py -q
  • Not completed: local dependency installation did not finish; the initial system-Python run failed during collection because fastapi is not installed. The existing regression test test_migrate_from_sqlalchemy_pickle_preserves_nested_safe_actions_pickle covers the reported failure path.

Manual End-to-End (E2E) Tests:

Not run; this is an offline migration/unpickling change covered by the unit test.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have added or updated unit tests for my change. (Existing regression test.)
  • All unit tests pass locally (blocked by incomplete dependency installation).
  • I have manually tested changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. (None.)

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.

Migration unpickler blocks builtins.getattr on py311 + crewai extras, silently dropping v0 EventActions during migration

2 participants