Skip to main content

Changing a default changes every caller that never set it

Updated 2 min readMarkdown
Changing a default changes every caller that never set it

when you change a function's default value, the diff shows one line. the change hits every caller that relied on the default, and none of those callers are in the diff.

a few ways this goes wrong.

a timeout default goes from 0 to 30. in that library 0 meant "no limit". a batch job that ran for ten minutes now dies at thirty seconds.

a limit flips meaning. somewhere 0 meant unlimited, now 0 means block everything, and the services that never set it stop accepting traffic.

a shared config key gets a new default for one team's feature, and three other services read the same key.

a feature flag gets reused. Knight Capital's 2012 incident is the famous version, an old flag was repurposed, one server still had the old code behind it, and the firm lost over $400 million in under an hour.

reviewers can't catch this from the diff because the risky part is the callers that aren't in it. what helps:

search for callers before changing a default, not after. if there are a lot, add a new parameter and leave the old default alone.

treat config defaults as an API. changing one is a breaking change and should be versioned like one.

never reuse a flag name. retire the old one and make a new one.

this kind of change is why Tomosu reads the whole repo instead of only the diff. a one-line default change scores differently when forty files depend on it https://tomosu.ai/platform?utm_source=hashnode&utm_medium=post&utm_campaign=changing-defaults

About the author

  • Tomosu continuously scores every application and closes its reliability gaps across development, pre-merge and runtime, using the Production Reliability Index (PRI) and a multi-tier agentic system.

No comments yet. Be the first to comment.