Webhook icon
Schedule icon
Script icon
If icon
Log icon
SlackIncomingWebhook icon

Validate CSVs Against a Schema Contract

Enforce a CSV schema contract on inbound files — columns, row limits, non-empty fields — and alert on breakage.

Categories
Data

Every integration dies the same way: a partner adds a column, drops one, or sends 4M rows instead of 40k. This blueprint validates inbound CSVs against a JSON contract — required columns, a row ceiling, and columns that must never be empty — and tells Slack exactly which rule broke when one does.

How it works

  1. validate_csv (io.kestra.plugin.scripts.python.Script) downloads the CSV, inspects headers and rows, and emits rows, violations, valid via the ::{"outputs": ...}:: protocol.
  2. check_contract (io.kestra.plugin.core.flow.If) branches: valid → log_valid; violations → alert_violations with the violation list.
  3. The errors block alerts Slack when the file can't be read or the schema is malformed.
  4. Triggers: a Webhook (csv-contract-check) for upload pipelines plus a disabled daily Schedule.

What you get

  • A real contract gate on partner/vendor files.
  • Violation messages that name the rule that broke.
  • validation_result JSON for routing or quarantine steps.

Who it's for

  • Data teams ingesting vendor or partner CSVs.
  • RevOps teams expecting clean CRM exports.
  • Anyone who has debugged "the file format changed" at 11pm.

Why orchestrate this with Kestra

A pandas snippet in a wiki tells you once; the flow runs it on every arrival, branches on the result, alerts, and logs — and the next step (quarantine the file, open a ticket, notify the vendor) is one task away.

Prerequisites

  • The CSV URL reachable from the Kestra Worker.
  • A Slack webhook.

Secrets

  • SLACK_WEBHOOK_URL: webhook for violation and failure alerts.

Quick start

  1. Add the Slack webhook secret.
  2. Set csv_url and adjust schema_json to your contract.
  3. Run once and read validation_result.
  4. Wire the csv-contract-check webhook into your ingestion pipeline.

How to extend

  • Quarantine rejected files by moving them to an S3 prefix.
  • ForEach over several inbound files with per-file contracts.
  • Add type checks per column (dates parseable, emails shaped).

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.