Skip to content

Commit

Permalink
Merge pull request #3734 from uselagoon/environment-exists-validator
Browse files Browse the repository at this point in the history
fix: actually throw error in environmentExists if the environment doesn't exist
  • Loading branch information
tobybellwood authored Jun 7, 2024
2 parents 871dee3 + 1e1b3e6 commit 8ef9eac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions services/api/src/resources/environment/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export const Validators = (sqlClientPool: Pool) => ({
Sql.selectEnvironmentById(environmentId)
);

if (R.has('info', env)) {
throw new Error(`Environment ID ${environmentId} doesn't exist.`);
if (R.length(env) == 0) {
// environment doesn't exist, throw an unauthorized error
throw new Error(`Unauthorized: You don't have permission to "view" on "environment"`);
}
},
environmentsHaveSameProject: async (environmentIds: number[]) => {
Expand Down

0 comments on commit 8ef9eac

Please sign in to comment.