Detect references to removed versioned types - #11925
Detect references to removed versioned types#11925Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 2 commits into
Conversation
|
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. |
There was a problem hiding this comment.
🟢 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
validateAvailabilityForRefto emitincompatible-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
.chronusfixentry 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.
47cfee8 to
97a14e3
Compare
There was a problem hiding this comment.
🟡 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 intranslateAvailability; a source version can jump from a target version before the removal directly to one after it, so the translated value isAvailability.Unavailableand no key is everRemoved. If the source is alreadyAvailableat that key, the existingAddedcheck 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
| if ( | ||
| sourceVal === Availability.Available && | ||
| targetVal === Availability.Removed && | ||
| findAvailabilityAfterVersion(key, Availability.Removed, sourceAvail) === undefined | ||
| ) { |
Signed-off-by: Sylvester Kaczmarek <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
A moderate validation bug can leave a dangling reference unreported.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
| if ( | ||
| sourceVal === Availability.Available && | ||
| isFirstUnavailableVersion(key, targetAvail) && | ||
| findAvailabilityAfterVersion(key, Availability.Removed, sourceAvail) === undefined |
|
Addressed the cross-namespace skipped-removal case in 7d43190. The validator now catches the first transition into Removed or Unavailable, and the focused versioning suite passes 66 runnable tests with 1 skipped. |
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: