fix: [Bug]: PySDK V3: pydantic-core (2.42.0) incompatibility with sagemaker.ai_regist (5652) by aviruthen · Pull Request #5728 · aws/sagemaker-python-sdk

Description

The issue is a pydantic/pydantic-core version incompatibility. sagemaker-core declares 'pydantic>=2.0.0,<3.0.0' as a dependency but does NOT declare pydantic-core. Pydantic requires an exact matching pydantic-core version (e.g., pydantic 2.11.5 requires pydantic-core==2.41.5). When users run 'pip install --force-reinstall', pip may resolve pydantic-core to a newer version (e.g., 2.42.0) that is incompatible with the installed pydantic version. This causes a SystemError at import time when any module transitively imports pydantic (e.g., DataSet → session_helper → pydantic). The fix is to either: (1) add pydantic-core as a dependency that will be co-resolved with pydantic, or (2) tighten pydantic constraints. The best approach is to let pydantic manage its own pydantic-core dependency but also exclude known-incompatible pydantic-core versions, plus add a runtime compatibility check that provides a helpful error message.

Related Issue

Related issue: 5652

Changes Made

  • sagemaker-core/pyproject.toml
  • sagemaker-core/src/sagemaker/core/_pydantic_compat.py
  • sagemaker-core/src/sagemaker/core/__init__.py
  • sagemaker-core/tests/unit/test_pydantic_compat.py

AI-Generated PR

This PR was automatically generated by the PySDK Issue Agent.

  • Confidence score: 85%
  • Classification: bug
  • SDK version target: V3

Merge Checklist

  • Changes are backward compatible
  • Commit message follows prefix: description format
  • Unit tests added/updated
  • Integration tests added (if applicable)
  • Documentation updated (if applicable)