Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): update GET /configs/jwt-customizer/:tokenPath API error handling #5595

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/core/src/libraries/logto-config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
LogtoConfigs,
cloudApiIndicator,
cloudConnectionDataGuard,
logtoOidcConfigGuard,
LogtoOidcConfigKey,
jwtCustomizerConfigGuard,
LogtoConfigs,
} from '@logto/schemas';
import type { LogtoOidcConfigType, LogtoJwtTokenKey, CloudConnectionData } from '@logto/schemas';
import chalk from 'chalk';
Expand All @@ -13,10 +13,8 @@ import { z, ZodError } from 'zod';
import RequestError from '#src/errors/RequestError/index.js';
import type Queries from '#src/tenants/Queries.js';
import { consoleLog } from '#src/utils/console.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

export type LogtoConfigLibrary = ReturnType<typeof createLogtoConfigLibrary>;
const { table } = convertToIdentifiers(LogtoConfigs);

export const createLogtoConfigLibrary = ({
logtoConfigs: {
Expand Down Expand Up @@ -87,8 +85,8 @@ export const createLogtoConfigLibrary = ({
// If the record does not exist (`rows` is empty)
if (rows.length === 0) {
throw new RequestError({
code: 'entity.not_exists',
name: table,
code: 'entity.not_exists_with_id',
name: LogtoConfigs.tableSingular,
id: key,
status: 404,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/integration-tests/src/tests/api/logto-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('admin console sign-in experience', () => {
};

await expectRejects(getJwtCustomizer('access-token'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
await expectRejects(deleteJwtCustomizer('access-token'), {
Expand All @@ -163,7 +163,7 @@ describe('admin console sign-in experience', () => {
);
await expect(deleteJwtCustomizer('access-token')).resolves.not.toThrow();
await expectRejects(getJwtCustomizer('access-token'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
});
Expand All @@ -176,7 +176,7 @@ describe('admin console sign-in experience', () => {
};

await expectRejects(getJwtCustomizer('client-credentials'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
await expectRejects(deleteJwtCustomizer('client-credentials'), {
Expand All @@ -202,7 +202,7 @@ describe('admin console sign-in experience', () => {
);
await expect(deleteJwtCustomizer('client-credentials')).resolves.not.toThrow();
await expectRejects(getJwtCustomizer('client-credentials'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
});
Expand Down
Loading