← LeaderboardThe Skill Leaderboard

avro-schema-evolution-audit

Audit Apache Avro writer-reader schema compatibility offline with binary encoding/decoding across defaults, numeric promotions, unions, aliases, enums, and direction rules.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: avro-schema-evolution-auditdescription: "Audit Apache Avro writer-reader schema compatibility offline with binary encoding/decoding across defaults, numeric promotions, unions, aliases, enums, and direction rules."category: datarisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [avro, schema-evolution, serialization, compatibility, fastavro, testing]

Avro Schema Evolution Audit

Overview

Verify Apache Avro writer-reader schema evolution offline using real binary encoding and decoding (fastavro.schemaless_writer and fastavro.schemaless_reader) grounded in the Apache Avro 1.12.0 schema resolution specification. Tests concrete schema changes in both directions (old writer -> new reader and new writer -> old reader), asserts exact decoded payloads and SchemaResolutionError failures, and separates pairwise compatibility checks from transitive registry guarantees.

Distinction from existing data and event-sourcing skills:

  • snowflake-development: covers Snowflake SQL, Snowpark, and VARIANT semi-structured queries rather than Avro binary schema resolution.
  • data-engineer and data-engineering-data-pipeline: provide broad ETL, Kafka, and lakehouse architecture patterns without executable Avro wire-compatibility checks.
  • event-sourcing-architect and event-store-design: model CQRS aggregates, projections, and snapshotting without testing Avro writer/reader binary evolution rules.

When to Use

  • Reviewing an Avro .avsc schema change before publishing producers or upgrading consumers.
  • Testing added fields with/without defaults, removed fields, numeric widening vs. disallowed narrowing, union branch evolution, field aliases, and enum symbol evolution (default fallback vs. resolution error).
  • Verifying backward (old writer -> new reader) and forward (new writer -> old reader) behavior locally before CI or staging rollout.
  • Do not use this skill to connect to production Confluent/AWS Glue Schema Registries or modify live compatibility settings.

Prerequisites

  • Python 3.10+ with fastavro (tested with Python 3.12.10, fastavro==1.13.1, and pytest==9.1.1).
  • Synthetic or sanitized writer/reader .avsc JSON schemas and representative sample records covering every union branch and enum symbol under test.
  • No production schema registry access, network requests, or live brokers required.

How It Works

1. Encode and decode real Avro binary frames

  1. Parse both schemas with fastavro.parse_schema(...) so invalid JSON or unknown types raise structured parse errors (SchemaParseException / UnknownType / ValueError).
  2. Encode each sample record with fastavro.schemaless_writer(buf, writer_schema, record) and decode using fastavro.schemaless_reader(buf, writer_schema, reader_schema).

2. Test both evolution directions and union branches

Run the local verification suite in avro evolution harness:

  1. Field addition & removal:
    • Added reader field with valid default: decodes old writer bytes with exact default (backward compatible).
    • Added required field without default: raises SchemaResolutionError on old writer data.
    • Removed field: new reader drops absent field cleanly (backward), while old reader without a default fails on new writer data (forward broken).
  2. Numeric promotions & narrowing:
    • Avro 1.12.0 permits int -> long/float/double, long -> float/double, float -> double; narrowing (long -> int, double -> float, double -> long) must raise SchemaResolutionError.
  3. Unions ([...]):
    • Test every relevant union branch independently (null branch passing never proves non-null branches like long vs. string resolve!).
  4. Aliases & enums:
    • Verify aliases remaps renamed fields during binary resolution.
    • Verify enum symbol additions and reader enum default fallback ("default": "UNKNOWN") vs. SchemaResolutionError when an unmapped symbol arrives.

3. Classify compatibility honestly (never overclaim transitivity)

Represent each direction separately as PASS, FAIL, NOT_TESTED, or INVALID_INPUT (backward_status, forward_status); classification is a truthful pairwise "<backward>/<forward> (pairwise samples only)" summary:

  • PASS: valid schema + ≥1 tested sample in that direction + every tested sample resolved.
  • FAIL: valid schema + ≥1 tested sample produced a genuine fastavro.read.SchemaResolutionError, no invalid inputs.
  • NOT_TESTED: no samples provided in that direction. Absent evidence is not failed compatibility; do not classify untested directions as incompatible. Both lists empty => NOT_TESTED/NOT_TESTED; valid old + no new => backward PASS, forward NOT_TESTED.
  • INVALID_INPUT: invalid schema (SchemaParseException/UnknownType/ValueError/KeyError/TypeError) or invalid record input (not a valid record for the writer schema; ValidationError/TypeError/ValueError/KeyError). Invalid schema/record inputs are distinguished from genuine SchemaResolutionError compatibility failures (invalid_inputs vs resolution_errors).

Explicitly note:

  • Pairwise sample-only limitation preserved: a passing test on a single schema pair (v1, v2) or subset of sample records cannot prove structural compatibility across all possible records or untested union branches, nor transitive compatibility (BACKWARD_TRANSITIVE, FORWARD_TRANSITIVE, FULL_TRANSITIVE) across [v0, v1, v2, ...] histories. Do not claim structural or transitive compatibility.

Examples

Run the self-contained suite in avro evolution harness:

User request: "Check whether adding 'currency' and renaming 'amount' breaks our order-event Avro consumers."
Inputs: Pairwise writer/reader .avsc schemas and representative union/enum samples.
Expected result: Backward checks decode defaults and aliased fields cleanly; missing defaults and incompatible
  numeric narrowing raise SchemaResolutionError; union checks test both null and non-null branches separately;
  report labels output as pairwise sample compatibility only (not universal or transitive).

Limitations

  • Pairwise binary sample testing only proves resolution for the inspected schema pair and exercised branches; schema registries (BACKWARD_TRANSITIVE, FORWARD_TRANSITIVE, FULL_TRANSITIVE) check full structural equivalence rules across every prior version.
  • Uses fastavro (1.13.1) Python resolution; language bindings (Java Apache Avro SchemaCompatibility, C++, Go) may enforce subtle default-type or logical-type validations differently.
  • Logical types (decimal, timestamp-millis, uuid) and schema-fingerprint wire framing (e.g., Confluent 5-byte magic prefix) are outside the raw schemaless_* resolution scope unless explicitly wrapped.

Safety and Side Effects

  • Strictly offline and read-only over local/synthetic schemas and in-memory BytesIO buffers.
  • Never connects to production schema registries, alters subject compatibility policies (PUT /config), or outputs unredacted private schemas/records.

Sources and related skills