Skip to content

Commit ba8cbc1

Browse files
committed
Add context to ForbiddenAccess error
1 parent 8cfb058 commit ba8cbc1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

opencti-platform/opencti-graphql/src/graphql/featureFlagDirective.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const makeFeatureFlagDirectiveTransformer = (): (schema: GraphQLSchema) =
4949
if (softFail) {
5050
return null;
5151
} else {
52-
throw ForbiddenAccess();
52+
throw ForbiddenAccess('Feature is disabled', { flags });
5353
}
5454
}
5555
return resolve(source, args, context, info);

opencti-platform/opencti-graphql/tests/01-unit/graphql/featureFlagDirective-test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ describe('featureFlagDirective', () => {
3333
const result = await graphql({ schema, source: '{ flaggedFeature }' });
3434

3535
expect(result.errors).not.toBeUndefined();
36-
expect(result.errors?.[0].message).toMatch(/You are not allowed to do this/i);
36+
expect(result.errors?.[0].message).toMatch(/Feature is disabled/i);
3737
expect(result.errors?.[0].extensions?.code).toMatch(/FORBIDDEN_ACCESS/i);
38+
expect(result.errors?.[0].extensions?.data).toMatchObject({
39+
flags: ['SOME_FLAG', 'SOME_OTHER_FLAG'],
40+
http_status: 403,
41+
});
3842
});
3943

4044
it('calls the resolver when one of the flags is enabled', async () => {

0 commit comments

Comments
 (0)