DataWeave partition() for Bulk API Responses: Stop Returning Silent 200 OKs
Our bulk import API returned 200 OK on every request. Nobody noticed that 40% of records were failing silently for 3 days. TL;DR partition() from dw::core::Arrays splits an array into success/failu...

Source: DEV Community
Our bulk import API returned 200 OK on every request. Nobody noticed that 40% of records were failing silently for 3 days. TL;DR partition() from dw::core::Arrays splits an array into success/failure groups in one pass Build summary (total, succeeded, failed, successRate) + per-record results + error extraction Empty batch trap: successCount / total * 100 divides by zero on empty arrays The caller needs to know EXACTLY what failed and why — not just "200 OK" The Problem: Silent Bulk Failures We had a bulk import API. Clients sent 5,000-10,000 records per batch. The API processed each record individually — some succeeded, some failed (duplicate keys, invalid formats, missing fields). The old response: {"status": "OK", "message": "Batch processed"} That's it. No per-record status. No failure count. No error details. The client had no idea which records failed. They found out 3 days later when reconciliation showed missing data. The Solution: partition() + Summary Builder %dw 2.0 import p