Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 176 176
=========================================
Hits 176 176 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new FlagKey type (a string alias) to provide stronger type safety for flag keys throughout the codebase. The change replaces raw string usage with the typed FlagKey across the domain model, service layer, repository interface, and handler layer.
Key changes:
- Introduced
type FlagKey stringin the flags package to create a distinct type for flag keys - Updated all struct fields, method signatures, and conversions to use
FlagKeyinstead of raw strings - Added comprehensive validation tags to request/response models for API constraints
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/flags/types.go | Defines the new FlagKey type and updates Flag and EvalResult structs to use it |
| internal/flags/service.go | Updates the Evaluate method signature to accept FlagKey parameter |
| internal/flags/repository.go | Updates the Repository interface Get method to accept FlagKey parameter |
| internal/flags/memory.go | Updates the in-memory repository implementation to use map[FlagKey]Flag and converts method signatures |
| internal/handler/models.go | Updates response models to use FlagKey type and adds validation tags for enum values and constraints |
| internal/handler/handler.go | Updates the FlagService interface and adds type conversion when calling service methods |
| internal/handler/mapper.go | Adds explicit conversion from string to FlagKey when mapping request bodies |
| internal/handler/handler_test.go | Updates test expectations and mock setup to use FlagKey type |
| internal/handler/mapper_test.go | Updates test assertions to expect FlagKey type |
| internal/handler/mock_service_test.go | Updates generated mock to match new interface signature |
| internal/flags/service_test.go | Updates test assertions to expect FlagKey type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Evaluate(gomock.Any(), "my-flag", gomock.Any()). | ||
| Evaluate(gomock.Any(), flags.FlagKey("my-flag"), gomock.Any()). | ||
| Return(flags.EvalResult{ | ||
| FlagKey: "my-flag", |
There was a problem hiding this comment.
The FlagKey field should use the flags.FlagKey type for consistency. Change this to FlagKey: flags.FlagKey("my-flag") to match the new type system.
| FlagKey: "my-flag", | |
| FlagKey: flags.FlagKey("my-flag"), |
| Evaluate(gomock.Any(), "premium-feature", gomock.Any()). | ||
| Evaluate(gomock.Any(), flags.FlagKey("premium-feature"), gomock.Any()). | ||
| Return(flags.EvalResult{ | ||
| FlagKey: "premium-feature", |
There was a problem hiding this comment.
The FlagKey field should use the flags.FlagKey type for consistency. Change this to FlagKey: flags.FlagKey("premium-feature") to match the new type system.
| FlagKey: "premium-feature", | |
| FlagKey: flags.FlagKey("premium-feature"), |
| Evaluate(gomock.Any(), "disabled-flag", gomock.Any()). | ||
| Evaluate(gomock.Any(), flags.FlagKey("disabled-flag"), gomock.Any()). | ||
| Return(flags.EvalResult{ | ||
| FlagKey: "disabled-flag", |
There was a problem hiding this comment.
The FlagKey field should use the flags.FlagKey type for consistency. Change this to FlagKey: flags.FlagKey("disabled-flag") to match the new type system.
| FlagKey: "disabled-flag", | |
| FlagKey: flags.FlagKey("disabled-flag"), |
| @@ -69,7 +69,7 @@ func TestService_Evaluate_ReturnsDefault(t *testing.T) { | |||
| result, err := svc.Evaluate(ctx, "my-flag", flags.EvalContext{}) | |||
There was a problem hiding this comment.
The Evaluate method now expects a flags.FlagKey type, not a string. Change this to svc.Evaluate(ctx, flags.FlagKey("my-flag"), flags.EvalContext{}) for type consistency.
No description provided.