0002 — Classify outcomes by a stable signal, not by a tool’s output text

Status

Accepted.

Context

Several places in Magda decide whether an external tool succeeded — or which kind of failure occurred — by matching that tool’s human-readable output. Three real examples, all in database/backup plumbing:

This is fragile for reasons that are easy to miss until they bite in production:

And both failure directions are silent: a benign result misreported as an error (noise that trains operators to ignore the message), or a real error misread as benign (silent data/retention loss).

Decision

Do not decide a program’s success/failure — or which kind of failure — by matching its human-readable output. Decide from a stable, machine-readable signal instead:

so that a non-zero exit is unambiguous and the classification does not depend on prose. Prefer establishing the state up front (so the tool is only invoked when it should succeed) over interpreting an error after the fact.

Each site that must distinguish outcomes this way should add a test that fails if the logic regresses to prose-matching.

Consequences

Where this is applied

Keep this list in sync; add new sites here.

Enforcing tests: magda-db-migrator/tests/migrate-idempotency.sh (cases 4/5) and deploy/helm/magda-core/tests/walg-backup-cronjob.sh (cases C/D/E).

Alternatives considered