Datasets:
D9: JSON Schema Validation Pipeline
Goal
Fix a JSON data pipeline (pipeline.py) that validates incoming records against a schema.
The pipeline has 3 schema validation bugs and 2 type coercion bugs.
Hard Requirements
Schema Validation Bugs
- Missing required field check: The validator does not reject records missing the
emailfield — it should. - Wrong type check for
age: The validator accepts string ages like"25"— it must require integer type. - Enum validation broken: The
statusfield should only accept["active", "inactive", "pending"]but the check is case-sensitive and rejects"Active". Fix: normalize to lowercase before checking.
Type Coercion Bugs
- Timestamp coercion: The
created_atfield is a Unix timestamp (integer) but the output serializer writes it as a string. Fix: keep as integer in output JSON. - Boolean coercion: The
verifiedfield accepts"true"/"false"strings but should coerce them to actual JSON booleans in the output.
Pipeline
- Input:
data/input/records.json(array of objects) - Schema:
data/schema.json - Valid output:
data/output/valid.json - Invalid output:
data/output/invalid.json(with rejection reasons) - Run:
python pipeline.py
Deliverables
- Fixed
pipeline.py - Correct output files
- Verifier confirms all 5 bugs fixed.