Skip to content

changeset version drops the upper bound of a compound (>=x <y) dependency range, silently #2271

Closed

Description

@mnattanmai

Summary

changeset version rewrites a compound (>=x.y.z <a.b.c) internal dependency range down to a bare >=x.y.z — silently dropping the upper bound — whenever updateInternalDependencies touches that dependency. This is worse than not rewriting at all: the resulting range has no ceiling, so it will admit any future major of that dependency, silently, forever, until someone notices and hand-restores the ceiling.

Reproduced on both @changesets/[email protected] and the current latest, 3.0.1.

Minimal reproduction

packages/pkg-a/package.json:
{ "name": "pkg-a", "version": "1.0.0" }

packages/pkg-b/package.json:
{
  "name": "pkg-b",
  "version": "1.0.0",
  "dependencies": { "pkg-a": ">=1.0.0 <2.0.0" }
}

.changeset/config.json:
{ "updateInternalDependencies": "patch", "fixed": [], "linked": [], "ignore": [] }

.changeset/repro.md:
---
"pkg-a": major
---
trigger a major bump on pkg-a
npm install   # link the workspace (needed on 3.0.1; 2.31.1 doesn't require this step)
npx @changesets/cli version

Expected: pkg-b's dependency on pkg-a is updated to a range that (a) admits the new 2.0.0 and (b) still has some upper bound reflecting that pkg-b was only ever verified against pkg-a 1.x, e.g. >=1.0.0 <3.0.0 or at minimum unchanged-shape reasoning applied to the new floor.

Actual, on both 2.31.1 and 3.0.1:

-  "dependencies": { "pkg-a": ">=1.0.0 <2.0.0" }
+  "dependencies": { "pkg-a": ">=2.0.0" }

The ceiling is gone. pkg-b will now silently accept [email protected], 4.0.0, or any future major, with zero further signal — no CI failure, no lint warning, nothing. Since the whole reason a package would use a compound range instead of a plain caret is to declare compatibility with more than one existing major (e.g. spanning both a pre-1.0 and a post-1.0 generation of a dependency during a migration window), losing the ceiling defeats the specific reason that range shape was chosen.

Why this is worse than "unsupported input"

A tool that refuses to touch a range shape it doesn't understand would be a minor inconvenience (a manual fix once). What actually happens is worse: it does rewrite it, to something looks plausible (a valid, still-passing semver range) but is silently wrong, in the least safe direction (no ceiling at all rather than too tight a ceiling). Nothing in changeset version's output flags that a compound range collapsed — the run reports success ("All files have been updated") with no warning that a dependency's declared compatibility window just got wider than anyone verified.

Real-world impact (two independent occurrences, same class)

This was hit twice in the same week in a real monorepo, on two separate releases:

  1. A tool package depended on six sibling packages via >=x.y.z <1.0.0 ranges (deliberately spanning a pre-1.0 window). When one of those six went to 1.0.0, all six ranges were rewritten to bare >=1.0.0, dropping every ceiling in one pass — even the five that hadn't changed version at all in that release.
  2. The following release, after those ceilings were hand-restored to >=x.y.z <2.0.0/<3.0.0, a second package crossed another major. The same six ranges were clobbered again, this time down to a bare floor with no ceiling whatsoever (e.g. >=0.7.0 <3.0.0 → >=2.0.0).

Both times, npm install/CI kept working — nothing failed loudly, because a floor-only range still legitimately resolves the currently-published version. The defect is invisible until a future major actually publishes and gets silently accepted.

Suggested fix directions (any of these would help)

  • Detect a range that doesn't match the simple ^/~/exact shapes changesets already knows how to bump, and leave it untouched with a printed warning, rather than silently rewriting it.
  • If rewriting a compound range is intended behavior, preserve the shape: bump the floor to the new version and shift the ceiling by the same relative amount (e.g. floor's major +1) rather than dropping the ceiling clause entirely.
  • At minimum, log a warning line during changeset version whenever a range containing a < clause is about to be rewritten, so this doesn't ship silently.

Happy to provide the exact repo/commit shape from the real-world case if useful (kept generic here since the underlying repos are private).

Activity

  1. beeequeue commented on Aug 26, 2026

    @beeequeue
    Member

    the range you use as an example >=1.1.0 <2.0.0 is literally just ^1.1.0 but written in a more convoluted and less idiomatic way. for now you can just use the normal caret ranges as a workaround.

    im not sure how it currently behaves for ranges such as ^2 || ^3 when 4.0.0 is available


    as a side note, please don't use LLMs to dump a giant blob of text into people's lap, it takes a lot of effort to read and parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions