Skip to content

Commit 577b85e

Browse files
authored
need better error mesasge when flag key is not found in the project
1 parent 9cda470 commit 577b85e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

internal/dev_server/model/override.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@ func getFlagStateForFlagAndProject(ctx context.Context, projectKey, flagKey stri
2525
return FlagState{}, err
2626
}
2727

28-
var flagExists bool
29-
for flag := range project.AllFlagsState {
30-
if flagKey == flag {
31-
flagExists = true
32-
break
33-
}
34-
}
35-
if !flagExists {
36-
return FlagState{}, ErrNotFound
28+
flagState, ok := project.AllFlagsState[flagKey]
29+
if !ok {
30+
return FlagState{}, fmt.Errorf("%w: projectKey=%q flagKey=%q", ErrFlagNotFound, projectKey, flagKey)
3731
}
38-
return project.AllFlagsState[flagKey], nil
32+
33+
return flagState, nil
3934
}
4035

4136
func UpsertOverride(ctx context.Context, projectKey, flagKey string, value ldvalue.Value) (Override, error) {

0 commit comments

Comments
 (0)