The first stage is the hardest to get right
Most pipeline failures live in the extract stage, because that's where your code touches systems you don't control. APIs throttle you, return malformed JSON on Tuesdays, and change response schemas without telling you. CSV exports change format after a vendor upgrade. Databases drift their column types as ORMs evolve. The discipline of extract is to capture the source-of-truth bytes faithfully, log what you got, and let validation fight the type wars in a separate stage.
The two patterns
- Bulk full extract — pull the entire source every run. Simple, idempotent, no state. Fine when the source is small or rarely changes.
- Incremental extract — pull only what's changed since the last run, using a watermark column (
updated_at >= last_run) or a change feed. Faster, but you have to manage the watermark.
The non-negotiables
- Retries with exponential backoff on transient errors (HTTP 429/5xx).
- Pagination handled correctly — most APIs return ≤1000 rows per page; loop until the last page returns less than a full page or the API tells you it's done.
- Capture the raw response, not just the parsed result. If the API returns junk on Tuesday, you want the raw JSON to debug from.
- Set a User-Agent identifying your pipeline. When the upstream operator emails about traffic spikes, they should be able to find you.