Skip to content

Commit

Permalink
fix(flags): change findUnique to findFirst for feature flag retrieval…
Browse files Browse the repository at this point in the history
… and enhance user validation
  • Loading branch information
cstrnt committed Feb 17, 2025
1 parent e2c2780 commit b78c5f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion apps/web/src/server/trpc/router/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,18 @@ export const flagRouter = router({
})
)
.query(async ({ ctx, input }) => {
return ctx.prisma.featureFlagValue.findUnique({
return ctx.prisma.featureFlagValue.findFirst({
where: {
id: input.flagValueId,
flag: {
project: {
users: {
some: {
userId: ctx.session.user.id,
},
},
},
},
},
include: {
environment: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function validate<T extends Record<string, ValidatorType>>(
continue;
}

returnObject[key] = value as Infer<typeof validator>;
returnObject[key] = value as Infer<T[typeof key]>;
}
if (errors.length > 0) {
return { errors };
Expand Down

0 comments on commit b78c5f7

Please sign in to comment.