Skip to content

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: BaseModel Pydantic v2 + _sdk_fields() introspection of the snowflake.core SDK
  • Option B: JSON Schema validation (jsonschema library)

Direct inheritance from snowflake.core models was also evaluated and ruled out: the SDK models are custom _generated classes, not Pydantic v2 BaseModelmodel_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.core changes internal _generated class structure, _sdk_fields() breaks silently. Mitigated by pinning the snowflake package version and running the test suite on each bump.