Overview
Introduction
This tool takes a list of integers and deliberately corrupts a chosen number of them, one digit-level mistake per corrupted line, so you can see how a parser or validator downstream reacts to slightly malformed numeric input.
Because it uses a seeded pseudo-random generator instead of true randomness, the exact same input, error count, and seed always produce the exact same corrupted output, which makes it usable as a repeatable test fixture generator.
What Is Integer Error Introducer?
A deterministic corruption tool for lists of integers, one value per line, that picks a specified number of lines and applies exactly one digit-level mutation to each.
The four possible mutations are: swapping two adjacent digits, deleting a digit, duplicating a digit, or changing a digit to a different one. Every other line in the list passes through completely unchanged.
How Integer Error Introducer Works
The list is parsed and validated first; every non-blank line must be a plain integer (an optional leading '-' followed by digits only), or the tool reports which line failed.
A mulberry32 pseudo-random generator is seeded from your chosen seed value, then used to shuffle the line indices and pick the first (clamped) error-count worth of them as corruption targets.
For each targeted line, the sign is set aside, and the digits are mutated with one randomly chosen type, rotating to the next type if the first choice has nothing to act on (like swapping digits in a single-digit number), so the target line is always actually altered.
When To Use Integer Error Introducer
Use it to generate malformed-but-plausible integer test fixtures for a parser, validator, or CSV/JSON ingestion pipeline you're testing.
It's also useful for demonstrating to a team how subtly corrupted numeric data (one flipped digit, one dropped digit) can slip past naive validation.
Often used alongside Integer Digit Error Introducer, Integer Fuzzer and Integer Digit Fuzzer.
Features
Advantages
- Fully deterministic and reproducible given the same input, error count, and seed, unlike using Math.random().
- Leaves every untouched line byte-for-byte identical to the input, so it's easy to diff the corrupted output against the original.
- Silently clamps an oversized error count instead of failing, so you don't need to pre-compute your list's length.
Limitations
- Mutations can produce a leading zero (e.g. 123 becoming 023) since the corruption intentionally doesn't re-normalize the result; this is expected, since real malformed input can include exactly that.
- Only works on whole decimal integers, one per line; it doesn't understand floating-point values, thousands separators, or other numeric formats.
- The set of possible mutations is fixed at four types; it isn't configurable per-run beyond how many lines get corrupted.
Examples
Best Practices & Notes
Best Practices
- Pick a specific seed value and record it alongside any test fixtures you generate, so the corruption can be reproduced later.
- Keep the error count well under your list length if you want most of the list to stay a reliable baseline for comparison.
Developer Notes
Uses a mulberry32 PRNG (seeded, never Math.random()) both to Fisher-Yates shuffle the candidate line indices and to pick/parameterize each mutation, mirroring this site's existing `addErrorsToYaml` pattern; mutation selection rotates through swap-adjacent, delete-digit, duplicate-digit, and change-digit (in a seed-determined starting order) until one actually produces a different string, since change-digit is guaranteed to always succeed as a fallback.
Integer Error Introducer Use Cases
- Generating reproducible malformed test fixtures for a numeric parser or import pipeline
- Demonstrating how digit-level typos can silently corrupt numeric data
- Stress-testing form validation on a list-of-numbers input field
Common Mistakes
- Assuming a different seed with the same error count will corrupt the same lines; changing the seed changes which lines are chosen, not just how they're mutated.
- Expecting corrupted output to always be the same length as the original line; delete and duplicate mutations change the digit count.
- Forgetting that an error count larger than the list length is clamped rather than rejected.
Tips
- Start with an error count of 1 to see exactly what a single mutation looks like before scaling up.
- Compare two seeds against the same list to see how differently the same error count can corrupt it.