riekelt/principal-engineer

handling-failures

Use when writing or touching any error path, catch block, fallback, default value, retry, or degraded mode - in any language, any repo.

Quelltext ansehen
Originales Skill-Dokument

Aus dem Quell-Repository gerendert; Überschriften, Beispiele, Code, Tabellen, Links und Bilder bleiben erhalten.

Handling failures

REQUIRED BACKGROUND: the principal-engineering skill.

Overview

A swallowed error is a bug with its evidence destroyed. Core contract: every failure path does exactly one of three things, and all three are loud. A system that looks healthy while serving wrong data is worse than one that crashes.

The contract

Every catch and failure path either:

  1. Logs at WARN or ERROR and rethrows, or
  2. Logs and returns a TYPED failure the caller must handle (a result type, a sealed error, a status the compiler or contract forces downstream code to acknowledge), or
  3. Logs and enters an explicitly documented degraded mode (named in the code and its documentation, with something observable saying the system is degraded).

Forbidden, no exceptions:

  • Bare catch-and-continue.
  • Catch-and-return-default (empty list, null, zero, cached copy) that masks the failure.
  • ?? fallback and its cousins where the fallback hides that the primary failed. A fallback is acceptable only when the absence is ALSO surfaced loudly elsewhere.

Corollaries

  • A missing required entry fails loud. Something absent from a registry, config, or catalog is a build or startup failure, never a silent default.
  • Error states are visible. A workflow must not appear healthy while failing; surface the error state in the UI, the metrics, or the logs someone actually watches.
  • Operator-facing remediation is specific. "connection failed, check REDIS_URL and whether redis responds to PING" beats "an error occurred".
  • Retries are bounded and observable.
  • Replays of side-effecting operations are idempotent.
  • Degraded modes have a bound. Skip-and-continue needs the explicit threshold where degradation becomes abort, as a named, operator-tunable constant. The guard must exist; its value is a judgment call to make with the owner. An unbounded degraded mode is a slow-motion swallow.
  • On failure paths, observability is part of the minimum, not gold-plating. The log line, the counter, and the alert ship with the fix; a failure path without them is the silent swallow with better intentions.

Touching existing swallows

Code you are editing that already swallows: fix it as part of the work, or explicitly flag it as owed with what it hides. Leaving it silently is endorsing it. In review, a NEW silent swallow is an automatic BLOCKER; a pre-existing one you touched and left unflagged is a WARNING against the change.

Common mistakes

  • "It should never happen" as a reason to swallow. Those paths are exactly the ones that need a loud alarm when they do.
  • Logging at DEBUG and calling it handled. If nobody sees it in production, it is a swallow with extra steps.
  • Catching broad (Exception, catch {}) to handle narrow. The unexpected failure dies silently beside the expected one.
  • A degraded mode nobody documented. Degradation only the author knows about is an outage the operator cannot diagnose.
  • Making the test pass by defaulting the failure. The test goes green; the defect graduates to production.
aus demselben Repository

Weitere Skills

Alle Skills
riekelt
Community

grounding-before-coding

Use when starting any non-trivial change, investigating a bug, or working in unfamiliar code - before the first line is written. Also use for pure investigation with no change planned yet - \"dig into this\", \"figure out why\", \"sometimes the export is empty\", intermittent errors after a deploy. Encodes the ground-first discipline: map the real code and data, quote evidence, never guess conventions. Use whenever a change or a conclusion is about to be built from belief instead of from the tree, even under time pressure.

Installationen
426
GitHub Stars
3
Aktualisiert
11. Sept.
riekelt
Community

keeping-one-source-of-truth

Use when adding data, config, state, constants, an enum-like string, a cache, or anything that could exist in two places - or when two sources already disagree. Encodes the one-fact-one-source doctrine for code and data: derive rather than store, extend the owner, absorb duplicates. Use at the moment copying a value feels faster than referencing it.

Installationen
426
GitHub Stars
3
Aktualisiert
11. Sept.
riekelt
Community

principal-engineering

Use when doing any non-trivial engineering work - implementing, debugging, refactoring, configuring, operating, or investigating why a system misbehaves - or any change where being wrong has a cost. Encodes the evidence-over-theory discipline, the hard safety rules, and the pre-change checkpoint. Use whenever code, data, or infrastructure is about to change or must be understood before it can, even if the task looks routine or is only "find out why". Foundation for the sibling skills.

Installationen
426
GitHub Stars
3
Aktualisiert
11. Sept.
riekelt
Community

writing-unit-tests

Use when writing or refactoring unit tests - a new test file, added cases, a flaky test, an unreadable one. Encodes behavior-first testing: one behavior per test, names that state the claim, deterministic setup, mocks only at boundaries you do not own. Use whenever a test is being written, even a quick one, and whenever a test needs a sleep, a mock of your own code, or a copy of the implementation's math.

Installationen
427
GitHub Stars
3
Aktualisiert
11. Sept.