Skip to content

Commit f3ba4be

Browse files
committed
check path
1 parent f85edfc commit f3ba4be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/management/identities/validations/identities.validation.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable, Logger, OnApplicationBootstrap} from '@nestjs/common';
1+
import {BadRequestException, Injectable, Logger, OnApplicationBootstrap} from '@nestjs/common';
22
import {parse} from 'yaml';
33
import {existsSync, readFileSync, readdirSync, writeFileSync} from 'fs';
44
import {ConfigObjectSchemaDTO} from './_dto/config.dto';
@@ -96,6 +96,10 @@ export class IdentitiesValidationService implements OnApplicationBootstrap {
9696
public async transformAttribute(key: string, attribute: any, data: any) {
9797

9898
const path = this.resolveConfigPath(key);
99+
if (path === null){
100+
this.logger.error('schema for ' + key + ' does not exist');
101+
throw new BadRequestException('schema for ' + key + ' does not exist');
102+
}
99103
const schema: any = parse(readFileSync(path, 'utf8'));
100104
this.logger.debug(`Additionalfields object transformation: ${JSON.stringify(data[key])}`);
101105
for (const [index, def] of Object.entries(schema?.properties || {})) {
@@ -245,6 +249,10 @@ export class IdentitiesValidationService implements OnApplicationBootstrap {
245249
*/
246250
public async validateAttribute(key: string, attribute: any, data: any): Promise<any | null> {
247251
const path = this.resolveConfigPath(key);
252+
if (path === null) {
253+
this.logger.error('schema for ' + key + ' does not exist');
254+
throw new BadRequestException('schema for ' + key + ' does not exist');
255+
}
248256
const schema: any = parse(readFileSync(path, 'utf8'));
249257

250258
for (const [index, def] of Object.entries(schema?.properties || {})) {

0 commit comments

Comments
 (0)