mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 22:27:22 +00:00
Update error-handling, show underprivileged notification error
This commit is contained in:
@@ -551,7 +551,7 @@ export const addMachineToWorkspace = async (req: Request, res: Response) => {
|
|||||||
const hasRequiredPrivileges = isAtLeastAsPrivilegedWorkspace(permission, rolePermission);
|
const hasRequiredPrivileges = isAtLeastAsPrivilegedWorkspace(permission, rolePermission);
|
||||||
|
|
||||||
if (!hasRequiredPrivileges) throw ForbiddenRequestError({
|
if (!hasRequiredPrivileges) throw ForbiddenRequestError({
|
||||||
message: "Failed to add a more privileged MI to workspace"
|
message: "Failed to add a more privileged MI to project"
|
||||||
});
|
});
|
||||||
|
|
||||||
let customRole;
|
let customRole;
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ export const requestErrorHandler: ErrorRequestHandler = async (
|
|||||||
|
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
|
|
||||||
delete (<any>error).stacktrace // remove stack trace from being sent to client
|
res.status((<RequestError>error).statusCode).send(
|
||||||
res.status((<RequestError>error).statusCode).json(error); // revise json part here
|
await error.format(req)
|
||||||
|
);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,9 +53,10 @@ export default class RequestError extends Error {
|
|||||||
){
|
){
|
||||||
|
|
||||||
super(message)
|
super(message)
|
||||||
this._logLevel = logLevel || LogLevel.INFO
|
this._logLevel = logLevel || LogLevel.INFO;
|
||||||
this._logName = LogLevel[this._logLevel];
|
this._logName = LogLevel[this._logLevel];
|
||||||
this.statusCode = statusCode
|
this.statusCode = statusCode;
|
||||||
|
this.message = message;
|
||||||
this.type = type
|
this.type = type
|
||||||
this.context = context || {}
|
this.context = context || {}
|
||||||
this.extra = []
|
this.extra = []
|
||||||
|
|||||||
+5
-2
@@ -236,9 +236,12 @@ export const AddMachineIdentityModal = ({
|
|||||||
|
|
||||||
reset();
|
reset();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
const error = err as any;
|
||||||
|
const text = error?.response?.data?.message
|
||||||
|
?? `Failed to ${popUp?.machineIdentity?.data ? "updated" : "created"} machine identity`;
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Failed to ${popUp?.machineIdentity?.data ? "updated" : "created"} machine identity`,
|
text,
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -101,8 +101,12 @@ export const AddMachineIdentityModal = ({
|
|||||||
handlePopUpToggle("machineIdentity", false);
|
handlePopUpToggle("machineIdentity", false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
const error = err as any;
|
||||||
|
const text = error?.response?.data?.message
|
||||||
|
?? "Failed to add machine identity to project";
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to add machine identity to project",
|
text,
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -23,6 +23,7 @@ type Props = {
|
|||||||
| "tags"
|
| "tags"
|
||||||
| "audit-logs"
|
| "audit-logs"
|
||||||
| "ip-allowlist"
|
| "ip-allowlist"
|
||||||
|
| "machine-identity"
|
||||||
| ProjectPermissionSub.SecretApproval;
|
| ProjectPermissionSub.SecretApproval;
|
||||||
isNonEditable?: boolean;
|
isNonEditable?: boolean;
|
||||||
setValue: UseFormSetValue<TFormSchema>;
|
setValue: UseFormSetValue<TFormSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user