mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-19 16:55:02 +02:00
fix(core): Validate data table sort columns
This commit is contained in:
parent
e065f78d1e
commit
ca1c7a9801
|
|
@ -299,6 +299,8 @@ export class DataTableController {
|
|||
} catch (e: unknown) {
|
||||
if (e instanceof DataTableNotFoundError) {
|
||||
throw new NotFoundError(e.message);
|
||||
} else if (e instanceof DataTableValidationError) {
|
||||
throw new BadRequestError(e.message);
|
||||
} else if (e instanceof Error) {
|
||||
throw new InternalServerError(e.message, e);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -335,6 +335,15 @@ export class DataTableService {
|
|||
|
||||
return await this.dataTableColumnRepository.manager.transaction(async (em) => {
|
||||
const columns = await this.dataTableColumnRepository.getColumns(dataTableId, em);
|
||||
if (dto.sortBy) {
|
||||
const [sortColumn] = dto.sortBy;
|
||||
if (
|
||||
!columns.some(({ name }) => name === sortColumn) &&
|
||||
!Object.hasOwn(DATA_TABLE_SYSTEM_COLUMN_TYPE_MAP, sortColumn)
|
||||
) {
|
||||
throw new DataTableValidationError(`unknown column name '${sortColumn}'`);
|
||||
}
|
||||
}
|
||||
const transformedDto = dto.filter
|
||||
? { ...dto, filter: this.validateAndTransformFilters(dto.filter, columns) }
|
||||
: dto;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user