Skip to content

Conversation

@sunshowers
Copy link
Collaborator

Several Problem and Fix variants inherently only apply to versioned APIs.
This change strengthens the type system by:

  • introducing VersionedApiSpecFileName and the lockstep equivalent
  • using them directly instead of ApiSpecFileName in several spots.

Also:

  • BlessedApiSpecFile now stores VersionedApiSpecFileName directly and
    provides versioned_spec_file_name() for type-safe access.
  • spec_files_generated.rs uses LockstepApiSpecFileName/VersionedApiSpecFileName.
  • latest_link is now always versioned.
  • Added test for malformed symlinks pointing to non-versioned targets.

Created using spr 1.3.6-beta.1
@sunshowers sunshowers changed the title [4/n] [dropshot-api-manager] use VersionedApiSpecFileName in Problem variants [4/n] [dropshot-api-manager] more type safety Jan 7, 2026
@sunshowers sunshowers requested a review from Copilot January 7, 2026 23:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances type safety in the dropshot-api-manager by introducing dedicated types for versioned and lockstep API spec filenames. The key insight is that several Problem and Fix variants inherently only apply to versioned APIs, not lockstep APIs.

Key changes:

  • Introduced VersionedApiSpecFileName and LockstepApiSpecFileName as distinct types
  • Refactored ApiSpecFileName from a struct with a kind field into an enum wrapping the two specialized types
  • Updated BlessedApiSpecFile to store and expose VersionedApiSpecFileName directly, enforcing the invariant that blessed files only exist for versioned APIs
  • Added comprehensive test coverage for malformed symlinks pointing to non-versioned targets

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/dropshot-api-manager-types/src/validation.rs Defines new LockstepApiSpecFileName and VersionedApiSpecFileName types, converts ApiSpecFileName to an enum, adds conversion methods and From trait implementations
crates/dropshot-api-manager/src/spec_files_blessed.rs Updates BlessedApiSpecFile to store VersionedApiSpecFileName directly with panic on lockstep APIs, adds versioned_spec_file_name() accessor, skips lockstep files during blessed file loading
crates/dropshot-api-manager/src/spec_files_generic.rs Updates parser functions to return specific types (VersionedApiSpecFileName, LockstepApiSpecFileName), consolidates hash checking logic using pattern matching on the enum
crates/dropshot-api-manager/src/spec_files_generated.rs Uses specific types when constructing filenames, converts to ApiSpecFileName via .into() when needed
crates/dropshot-api-manager/src/resolved.rs Updates Problem and Fix variants to use VersionedApiSpecFileName, adds type conversions using .into() and .as_versioned(), simplifies version access by removing unnecessary .expect() calls
crates/integration-tests/tests/integration/versioned.rs Adds comprehensive test for malformed "latest" symlinks pointing to non-versioned targets to ensure graceful error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants