ADR-0001 — Pydantic + _sdk_fields() over jsonschema
Update date : 2026-05-27 20:11
Status: accepted Date: 2026-05-26
Context
Two approaches were benchmarked for validating resource .yml files before deployment:
- Option A:
BaseModelPydantic v2 +_sdk_fields()introspection of thesnowflake.coreSDK - Option B: JSON Schema validation (
jsonschemalibrary)
Direct inheritance from snowflake.core models was also evaluated and ruled out: the SDK models
are custom _generated classes, not Pydantic v2 BaseModel — model_validate() is absent.
Decision
Option A: each resource is a BaseModel Pydantic v2. Field definitions are derived via _sdk_fields(),
which introspects the corresponding snowflake.core object at import time.
jsonschema is not a dependency.
Consequences
- Zero manual field mapping —
_sdk_fields()stays in sync automatically when Snowflake updates the SDK. - Validation is Pydantic-native: type coercion, error messages, IDE completion all work out of the box.
- Adding a new resource type = subclass
BaseResource, call_sdk_fields(). No schema file to maintain. - Risk: if
snowflake.corechanges internal_generatedclass structure,_sdk_fields()breaks silently. Mitigated by pinning thesnowflakepackage version and running the test suite on each bump.