Skip to content

Detect references to removed versioned types - #11925

Open
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 1 commit into
microsoft:mainfrom
sylvesterkaczmarek:fix/11807-removed-reference
Open

Detect references to removed versioned types#11925
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 1 commit into
microsoft:mainfrom
sylvesterkaczmarek:fix/11807-removed-reference

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Fixes #11807.

Report a dangling versioned reference when the target is removed while the source remains available. The check fires at the target removal boundary and preserves the existing removed-before diagnostic when the source is removed later.

Tests:

  • pnpm --filter @typespec/versioning build
  • pnpm --filter @typespec/versioning test
  • pnpm --filter @typespec/versioning lint
  • pnpm chronus verify

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, adds a targeted regression test, and includes the required .chronus fix entry.

Pull request overview

This PR fixes a gap in @typespec/versioning reference validation by reporting a diagnostic when a referencing type remains available across a version boundary where the referenced type is removed, preventing dangling $refs in versioned outputs.

Changes:

  • Extend validateAvailabilityForRef to emit incompatible-versioned-reference (doesNotExist) at the referenced-type removal boundary when the referrer remains available.
  • Add a regression test covering the “target removed while referrer remains available” scenario.
  • Add a .chronus fix entry for @typespec/versioning.
File summaries
File Description
packages/versioning/src/validate.ts Adds a new diagnostic branch to catch references to types removed while the source remains available.
packages/versioning/test/incompatible-versioning.test.ts Adds a regression test asserting the new diagnostic message for the removed-target case.
.chronus/changes/fix-removed-reference-validation-2026-09-10.md Adds a changelog entry documenting the fix in @typespec/versioning.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Validation still has unresolved cases for re-added and non-present targets.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

packages/versioning/src/validate.ts:853

  • This only handles targetVal === Availability.Removed, but cross-namespace dependency maps are translated at the source keys in translateAvailability; a source version can jump from a target version before the removal directly to one after it, so the translated value is Availability.Unavailable and no key is ever Removed. If the source is already Available at that key, the existing Added check also does not fire, leaving the dangling reference undiagnosed. Please cover both non-present states and emit only at the first transition after the target removal.
      sourceVal === Availability.Available &&
      targetVal === Availability.Removed &&
      findAvailabilityAfterVersion(key, Availability.Removed, sourceAvail) === undefined
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +850 to +854
if (
sourceVal === Availability.Available &&
targetVal === Availability.Removed &&
findAvailabilityAfterVersion(key, Availability.Removed, sourceAvail) === undefined
) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Versioning misses a reference to a type removed before the referrer, emitting a dangling ref with no diagnostic

2 participants