mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 14:27:30 +00:00
feat: made missing errors as internal server error and added depth in scim knex
This commit is contained in:
@@ -11,8 +11,11 @@ const appendParentToGroupingOperator = (parentPath: string, filter: Filter) => {
|
|||||||
const processDynamicQuery = (
|
const processDynamicQuery = (
|
||||||
rootQuery: Knex.QueryBuilder,
|
rootQuery: Knex.QueryBuilder,
|
||||||
scimRootFilterAst: Filter,
|
scimRootFilterAst: Filter,
|
||||||
getAttributeField: (attr: string) => string | null
|
getAttributeField: (attr: string) => string | null,
|
||||||
|
depth = 0
|
||||||
) => {
|
) => {
|
||||||
|
if (depth > 10) return;
|
||||||
|
|
||||||
const stack = [
|
const stack = [
|
||||||
{
|
{
|
||||||
scimFilterAst: scimRootFilterAst,
|
scimFilterAst: scimRootFilterAst,
|
||||||
@@ -76,7 +79,7 @@ const processDynamicQuery = (
|
|||||||
case "and": {
|
case "and": {
|
||||||
scimFilterAst.filters.forEach((el) => {
|
scimFilterAst.filters.forEach((el) => {
|
||||||
void query.andWhere((subQueryBuilder) => {
|
void query.andWhere((subQueryBuilder) => {
|
||||||
processDynamicQuery(subQueryBuilder, el, getAttributeField);
|
processDynamicQuery(subQueryBuilder, el, getAttributeField, depth + 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -84,14 +87,14 @@ const processDynamicQuery = (
|
|||||||
case "or": {
|
case "or": {
|
||||||
scimFilterAst.filters.forEach((el) => {
|
scimFilterAst.filters.forEach((el) => {
|
||||||
void query.orWhere((subQueryBuilder) => {
|
void query.orWhere((subQueryBuilder) => {
|
||||||
processDynamicQuery(subQueryBuilder, el, getAttributeField);
|
processDynamicQuery(subQueryBuilder, el, getAttributeField, depth + 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "not": {
|
case "not": {
|
||||||
void query.whereNot((subQueryBuilder) => {
|
void query.whereNot((subQueryBuilder) => {
|
||||||
processDynamicQuery(subQueryBuilder, scimFilterAst.filter, getAttributeField);
|
processDynamicQuery(subQueryBuilder, scimFilterAst.filter, getAttributeField, depth + 1);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -100,7 +103,8 @@ const processDynamicQuery = (
|
|||||||
processDynamicQuery(
|
processDynamicQuery(
|
||||||
subQueryBuilder,
|
subQueryBuilder,
|
||||||
appendParentToGroupingOperator(scimFilterAst.attrPath, scimFilterAst.valFilter),
|
appendParentToGroupingOperator(scimFilterAst.attrPath, scimFilterAst.valFilter),
|
||||||
getAttributeField
|
getAttributeField,
|
||||||
|
depth + 1
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -97,7 +97,11 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
|
|||||||
message
|
message
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
void res.send(error);
|
void res.status(HttpStatusCodes.InternalServerError).send({
|
||||||
|
statusCode: HttpStatusCodes.InternalServerError,
|
||||||
|
error: "InternalServerError",
|
||||||
|
message: "Something went wrong"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user