[4/n] [dropshot-api-manager] more type safety#41
Conversation
Created using spr 1.3.6-beta.1
There was a problem hiding this comment.
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
VersionedApiSpecFileNameandLockstepApiSpecFileNameas distinct types - Refactored
ApiSpecFileNamefrom a struct with akindfield into an enum wrapping the two specialized types - Updated
BlessedApiSpecFileto store and exposeVersionedApiSpecFileNamedirectly, 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several Problem and Fix variants inherently only apply to versioned APIs.
This change strengthens the type system by:
VersionedApiSpecFileNameand the lockstep equivalentApiSpecFileNamein several spots.Also:
BlessedApiSpecFilenow storesVersionedApiSpecFileNamedirectly andprovides
versioned_spec_file_name()for type-safe access.spec_files_generated.rsusesLockstepApiSpecFileName/VersionedApiSpecFileName.latest_linkis now always versioned.