On November 20, a test suite for an autonomous Claude Code agent running on a single Windows PC went red, revealing that a test designed to verify a 'nothing to post' state had unexpectedly modified three live DEV.to posts. The incident exposed a brittle testing pattern where stubs written in September failed to isolate production side effects from script updates made in October.
The Stub That Stopped Working
The developer, dbsoul, wrote the initial test on September 7 and refined it on September 25. Both versions stubbed the content picker to force a null state, assuming the posting script would exit immediately after finding no content. This logic held true until October 19, when a new series-attachment step was appended to the end of the same script. This step iterates through published posts to attach them to a series, making real API calls using a local key. The test was not updated when the script grew. From October 29, when the new step went live, until the test failed on November 20, the 'nothing to post' scenario still executed the new attachment logic. Because the test stubbed the content picker but not the new series step, the script ran the attachment logic against the live API, treating the null state as a trigger to check and edit existing posts.
Forensic Evidence in the API Logs
The damage was confirmed by reading the post metadata on November 21. Three specific posts, including ID 4628297, showed last-edited timestamps of 17:24:44, 17:24:51, and 17:25:01 (UTC+9) on November 20. These timestamps aligned perfectly with the test suite execution, not the scheduled production runs, which had already processed those posts on November 6. The 7- and 10-second gaps between edits matched the script's built-in 5-second delay between requests. The developer noted a critical observability gap: the script logged the result of each edit (success/failure) but not the reason for the edit. The code treated a failed read and a missing series ID identically, triggering an edit in both cases. Without logging the read response, it is impossible to know if the posts were actually missing from the series or if the read requests themselves failed, causing the script to attempt unnecessary writes.
The Fix and the Lesson
The incident prompted immediate changes to both the test suite and the production script. On November 20, the test was updated to stub the series step entirely, verifying it was called rather than allowing it to run. On November 21, the production script was hardened to distinguish between 'read failure' and 'no series,' ensuring that transient API errors do not trigger writes. The developer also added logging to capture the read response before any edit attempt.
Key Takeaways
- Tests that execute real scripts must account for future steps added to the pipeline, not just the state at the time of writing.
- 'Nothing to do' tests are high-risk if the script contains side-effecting steps that run unconditionally after the main logic.
- Distinguish between read failures and empty results in code to prevent unnecessary write operations on transient errors.
- Log the input state (e.g., read response) that triggers a write, not just the write result, to enable root cause analysis.
The Bottom Line
Tests that run real scripts must stub every side-effecting step, not just the ones that existed when the test was written. If your test suite executes production code paths, it must be maintained as actively as the code itself.