Skip to content
Back to skills

Avro Schema Evolution Audit

ASecurity

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

  • 50,717 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentspythongojavac++sqlawstestinggitdocumentation

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add sickn33/agentic-awesome-skills --skill avro-schema-evolution-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Avro Schema Evolution Audit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Avro Schema Evolution Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sickn33-avro-schema-evolution-audit/badge)](https://www.skillsdirectory.com/skills/sickn33-avro-schema-evolution-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: avro-schema-evolution-audit
description: "Audit Apache Avro writer-reader schema compatibility offline with binary encoding/decoding across defaults, numeric promotions, unions, aliases, enums, and direction rules."
category: data
risk: safe
source: self
source_type: self
date_added: "2026-12-01"
author: Koushik-Katkam
tags: [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](references/avro-evolution-harness.md):

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](references/avro-evolution-harness.md):

```text
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

- [Apache Avro 1.12.0 Specification — Schema Resolution](https://avro.apache.org/docs/1.12.0/specification/#schema-resolution)
- [fastavro documentation](https://fastavro.readthedocs.io/)
- Related skills: [snowflake-development](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/snowflake-development/SKILL.md), [data-engineer](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/data-engineer/SKILL.md), [data-engineering-data-pipeline](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/data-engineering-data-pipeline/SKILL.md), [event-sourcing-architect](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/event-sourcing-architect/SKILL.md), [event-store-design](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/event-store-design/SKILL.md).

Files in this skill

  • SKILL.md8.1 KB
  • references/avro-evolution-harness.md23.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.