Safeguard
Developer Tools•

How do I retire an insecure API in my library without breaking users?

Deprecate in a minor release, document the replacement, then remove in the next major. A timeline for retiring an unsafe function under SemVer.

Safeguard Security Team
4 min read

Deprecate the insecure function in a minor release, document the safe replacement, warn at runtime, and remove it in a later major release. Semantic Versioning asks for at least one minor release carrying the deprecation before removal. If the flaw is actively exploitable, ship a safe default now and say so loudly.

What SemVer requires

The specification's FAQ answers this directly. When you deprecate part of your public API, do two things: update your documentation to let users know about the change, and issue a new minor release with the deprecation in place. Before you completely remove the functionality in a new major release, there should be at least one minor release that contains the deprecation, so users can transition smoothly. The spec also says the minor version must be incremented when public API functionality is marked as deprecated.

A timeline

ReleaseWhat changesUsers see
2.5.0 minorSafe replacement added, old function marked deprecatedRuntime warning, docs updated
2.6.0 minorWarning points to the migration guide, optional strict mode errors on the old callOpt in to enforcement
3.0.0 majorOld function removed, safe behavior is the defaultBuild breaks if still used

Keep the gap between deprecation and removal long enough for users to act. State the dates or versions publicly.

Steps

  1. Add the replacement first. Users need somewhere to go before you take anything away.
  2. Mark the old function deprecated in code, docs and types, with a message naming the replacement.
  3. Emit a runtime warning once per process, not on every call.
  4. Write the migration guide with before and after examples.
  5. Add the entry under Deprecated in the changelog, and a Security entry if the reason is a vulnerability. Keep a Changelog defines both categories.
  6. Add an opt in strict mode that fails on deprecated calls, so careful users can find usages early.
  7. Remove in the next major and list it under Removed.

When the flaw is urgent

The slow path assumes the risk allows it. If the old API is exploitable in common configurations, you can also change the default in a minor release behind an explicit, documented setting that restores the old behavior, if you judge the change compatible for nearly all users. Be honest about this tradeoff: changing behavior in a minor release can surprise people, and SemVer requires a major for backward incompatible changes. When in doubt, ship the secure option off by default, tell users to turn it on, and make it the default in the major.

For high severity cases, also publish an advisory that explains the risk and the mitigation, independent of the version plan.

Tell users where they stand

A deprecation nobody notices is no deprecation at all. Use every channel: the changelog, release notes, the docs, the runtime warning and the registry's deprecation feature where one exists. See the guide on the breaking change notice template for wording.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how unsafe calls in code are found, which is how you can locate callers of the function you plan to retire.

Where Safeguard fits

Safeguard scans dependencies, runs reachability analysis to show which findings your code can actually reach, and can open fix pull requests through autonomous remediation. That last feature is off by default and every category starts on Manual, so a person approves each change. You can try a free scan on a repository first.

Quick check

Does deprecating a function require a major version?

No. SemVer says to issue a minor release with the deprecation, and remove the function later in a major release.

How many minor releases must carry the deprecation?

At least one before removal, per the SemVer FAQ. Allow more time for widely used APIs.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.