mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 01:05:40 +00:00
feat: more contextual not found errors
This commit is contained in:
@@ -66,7 +66,7 @@ export const identityProjectServiceFactory = ({
|
||||
const existingIdentity = await identityProjectDAL.findOne({ identityId, projectId });
|
||||
if (existingIdentity)
|
||||
throw new BadRequestError({
|
||||
message: `Identity with id ${identityId} already exists in project with id ${projectId}`
|
||||
message: `Identity with ID ${identityId} already exists in project with ID ${projectId}`
|
||||
});
|
||||
|
||||
const project = await projectDAL.findById(projectId);
|
||||
@@ -76,7 +76,7 @@ export const identityProjectServiceFactory = ({
|
||||
});
|
||||
if (!identityOrgMembership)
|
||||
throw new NotFoundError({
|
||||
message: `Failed to find identity with id ${identityId}`
|
||||
message: `Failed to find identity with ID ${identityId}`
|
||||
});
|
||||
|
||||
for await (const { role: requestedRoleChange } of roles) {
|
||||
@@ -104,7 +104,7 @@ export const identityProjectServiceFactory = ({
|
||||
})
|
||||
: [];
|
||||
if (customRoles.length !== customInputRoles.length)
|
||||
throw new NotFoundError({ message: "Custom project roles not found" });
|
||||
throw new NotFoundError({ message: "One or more custom project roles not found" });
|
||||
|
||||
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
||||
const projectIdentity = await identityProjectDAL.transaction(async (tx) => {
|
||||
@@ -166,7 +166,7 @@ export const identityProjectServiceFactory = ({
|
||||
const projectIdentity = await identityProjectDAL.findOne({ identityId, projectId });
|
||||
if (!projectIdentity)
|
||||
throw new NotFoundError({
|
||||
message: `Identity with id ${identityId} doesn't exists in project with id ${projectId}`
|
||||
message: `Identity with ID ${identityId} doesn't exists in project with ID ${projectId}`
|
||||
});
|
||||
|
||||
for await (const { role: requestedRoleChange } of roles) {
|
||||
@@ -192,7 +192,7 @@ export const identityProjectServiceFactory = ({
|
||||
})
|
||||
: [];
|
||||
if (customRoles.length !== customInputRoles.length)
|
||||
throw new NotFoundError({ message: "Custom project roles not found" });
|
||||
throw new NotFoundError({ message: "One or more custom project roles not found" });
|
||||
|
||||
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
||||
|
||||
@@ -237,8 +237,9 @@ export const identityProjectServiceFactory = ({
|
||||
projectId
|
||||
}: TDeleteProjectIdentityDTO) => {
|
||||
const identityProjectMembership = await identityProjectDAL.findOne({ identityId, projectId });
|
||||
if (!identityProjectMembership)
|
||||
throw new NotFoundError({ message: `Failed to find identity with id ${identityId}` });
|
||||
if (!identityProjectMembership) {
|
||||
throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });
|
||||
}
|
||||
|
||||
const { permission } = await permissionService.getProjectPermission(
|
||||
actor,
|
||||
@@ -314,7 +315,10 @@ export const identityProjectServiceFactory = ({
|
||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Identity);
|
||||
|
||||
const [identityMembership] = await identityProjectDAL.findByProjectId(projectId, { identityId });
|
||||
if (!identityMembership) throw new NotFoundError({ message: `Membership not found for identity ${identityId}` });
|
||||
if (!identityMembership)
|
||||
throw new NotFoundError({
|
||||
message: `Project membership for identity with ID '${identityId} in project with ID '${projectId}' not found`
|
||||
});
|
||||
return identityMembership;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user