# Self-Healing CI: Recovering Flaky External-Service Integration Tests

> Integration tests that hit external services flake on the service, not your code. See the manual fix and how self-healing CI retries the transient ones.

Source: https://latchkey.dev/learn/self-healing-ci/self-heal-flaky-integration-external  
Updated: 2026-06-25

When an integration test fails because the external service it calls was briefly slow or unavailable, the flake is upstream - the same test passes on a clean retry.

## What makes a failure safely retryable

Automatic retry is only correct for failures that are genuinely transient. Retrying a deterministic failure wastes minutes and hides a real defect, so the classification matters more than the retry mechanism.

- Safe to retry: network timeouts, registry 5xx, transient DNS failures, a service container that was not ready, a spot instance reclaimed mid-run.
- Not safe to retry: assertion failures, compile errors, lint violations, anything that fails identically on every attempt.
- Ambiguous, and worth investigating rather than retrying: out-of-memory kills, disk exhaustion, and flaky tests. These repeat under load and a retry only hides the trend.
- Always record that a retry happened. A pipeline that silently retries is a pipeline whose real failure rate you do not know.

## FAQ

### What causes Self-Healing CI: recovering flaky External-Service integration tests?

An integration test that exercises a real external service (an API, a sandbox endpoint, a third-party dependency) fails intermittently with a timeout, a 5xx, or a rate-limit from that service. Your code and the test are correct; a human re-runs the suite and it goes green with no change.

### How do I fix Self-Healing CI: recovering flaky External-Service integration tests manually?

[object Object]

### Can Self-Healing CI: recovering flaky External-Service integration tests be fixed automatically?

Self-healing CI treats external-dependency flakiness conservatively: it identifies failures that match a transient upstream signature (timeout, 5xx, rate-limit from the service) and retries those specifically, while leaving consistent, reproducible assertion failures to surface as real.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
