From e0a51384acb29e6e2d98f75156b943abb93ac8c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Mar 2022 04:10:09 +0000 Subject: [PATCH 1/2] build(deps): bump ajv from 7.0.3 to 8.10.0 Bumps [ajv](https://github.com/ajv-validator/ajv) from 7.0.3 to 8.10.0. - [Release notes](https://github.com/ajv-validator/ajv/releases) - [Commits](https://github.com/ajv-validator/ajv/compare/v7.0.3...v8.10.0) --- updated-dependencies: - dependency-name: ajv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .changeset/dependabot-2b68456.md | 7 +++++++ packages/catalog-model/package.json | 2 +- packages/config-loader/package.json | 2 +- .../package.json | 2 +- yarn.lock | 18 ++++-------------- 5 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 .changeset/dependabot-2b68456.md diff --git a/.changeset/dependabot-2b68456.md b/.changeset/dependabot-2b68456.md new file mode 100644 index 0000000000..f54dd17d55 --- /dev/null +++ b/.changeset/dependabot-2b68456.md @@ -0,0 +1,7 @@ +--- +'@backstage/catalog-model': patch +'@backstage/config-loader': patch +'@backstage/plugin-tech-insights-backend-module-jsonfc': patch +--- + +build(deps): bump `ajv` from 7.0.3 to 8.10.0 diff --git a/packages/catalog-model/package.json b/packages/catalog-model/package.json index e1ba4d8199..c7840b71b2 100644 --- a/packages/catalog-model/package.json +++ b/packages/catalog-model/package.json @@ -37,7 +37,7 @@ "@backstage/config": "^1.0.0", "@backstage/errors": "^1.0.0", "@backstage/types": "^1.0.0", - "ajv": "^7.0.3", + "ajv": "^8.10.0", "json-schema": "^0.4.0", "lodash": "^4.17.21", "uuid": "^8.0.0" diff --git a/packages/config-loader/package.json b/packages/config-loader/package.json index 260a2ca882..24ed7c140c 100644 --- a/packages/config-loader/package.json +++ b/packages/config-loader/package.json @@ -39,7 +39,7 @@ "@backstage/errors": "^1.0.0", "@backstage/types": "^1.0.0", "@types/json-schema": "^7.0.6", - "ajv": "^7.0.3", + "ajv": "^8.10.0", "chokidar": "^3.5.2", "fs-extra": "10.0.1", "json-schema": "^0.4.0", diff --git a/plugins/tech-insights-backend-module-jsonfc/package.json b/plugins/tech-insights-backend-module-jsonfc/package.json index b36c24803e..05e7d458f3 100644 --- a/plugins/tech-insights-backend-module-jsonfc/package.json +++ b/plugins/tech-insights-backend-module-jsonfc/package.json @@ -39,7 +39,7 @@ "@backstage/errors": "^1.0.0", "@backstage/plugin-tech-insights-common": "^0.2.4", "@backstage/plugin-tech-insights-node": "^0.2.8", - "ajv": "^7.0.3", + "ajv": "^8.10.0", "json-rules-engine": "^6.1.2", "lodash": "^4.17.21", "luxon": "^2.0.2", diff --git a/yarn.lock b/yarn.lock index 96d9301fae..e6500e57da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7248,20 +7248,10 @@ ajv@^6.10.0, ajv@^6.10.1, ajv@^6.12.2, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.5.5, ajv json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^7.0.3: - version "7.0.3" - resolved "https://registry.npmjs.org/ajv/-/ajv-7.0.3.tgz#13ae747eff125cafb230ac504b2406cf371eece2" - integrity sha512-R50QRlXSxqXcQP5SvKUrw8VZeypvo12i2IX0EeR5PiZ7bEKeHWgzgo264LDadUsCU42lTJVhFikTqJwNeH34gQ== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - -ajv@^8.0.0, ajv@^8.8.0: - version "8.9.0" - resolved "https://registry.npmjs.org/ajv/-/ajv-8.9.0.tgz#738019146638824dea25edcf299dcba1b0e7eb18" - integrity sha512-qOKJyNj/h+OWx7s5DePL6Zu1KeM9jPZhwBqs+7DzP6bGOvqzVCSf0xueYmVuaC/oQ/VtS2zLMLHdQFbkka+XDQ== +ajv@^8.0.0, ajv@^8.10.0, ajv@^8.8.0: + version "8.10.0" + resolved "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz#e573f719bd3af069017e3b66538ab968d040e54d" + integrity sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw== dependencies: fast-deep-equal "^3.1.1" json-schema-traverse "^1.0.0" From c0697dcf8805a4431761551c76c8145856dd5a7c Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 21 Mar 2022 10:25:50 +0100 Subject: [PATCH 2/2] chore: making the breaking change for this - perhaps a better way to do the deprecation though. Signed-off-by: blam --- .../policies/SchemaValidEntityPolicy.ts | 2 +- packages/catalog-model/src/validation/ajv.ts | 2 +- .../validation/entityKindSchemaValidator.ts | 2 +- .../src/lib/schema/compile.test.ts | 8 +++---- .../config-loader/src/lib/schema/compile.ts | 8 +++---- .../src/lib/schema/filtering.test.ts | 22 +++++++++---------- .../config-loader/src/lib/schema/filtering.ts | 2 +- .../config-loader/src/lib/schema/load.test.ts | 16 +++++++------- packages/config-loader/src/lib/schema/load.ts | 4 ++-- .../config-loader/src/lib/schema/types.ts | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.ts b/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.ts index 7f33e71f1c..1b5b7fe79b 100644 --- a/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.ts +++ b/packages/catalog-model/src/entity/policies/SchemaValidEntityPolicy.ts @@ -54,7 +54,7 @@ export class SchemaValidEntityPolicy implements EntityPolicy { } throw new Error( - `Malformed envelope, ${error.dataPath || ''} ${error.message}`, + `Malformed envelope, ${error.instancePath || ''} ${error.message}`, ); } } diff --git a/packages/catalog-model/src/validation/ajv.ts b/packages/catalog-model/src/validation/ajv.ts index c65c3df18a..15d0b674bf 100644 --- a/packages/catalog-model/src/validation/ajv.ts +++ b/packages/catalog-model/src/validation/ajv.ts @@ -41,7 +41,7 @@ export function throwAjvError( const error = errors[0]; throw new TypeError( - `${error.dataPath || ''} ${error.message}${ + `${error.instancePath || ''} ${error.message}${ error.params ? ` - ${Object.entries(error.params) .map(([key, val]) => `${key}: ${val}`) diff --git a/packages/catalog-model/src/validation/entityKindSchemaValidator.ts b/packages/catalog-model/src/validation/entityKindSchemaValidator.ts index 66259cc63d..dc5aa586aa 100644 --- a/packages/catalog-model/src/validation/entityKindSchemaValidator.ts +++ b/packages/catalog-model/src/validation/entityKindSchemaValidator.ts @@ -74,7 +74,7 @@ export function entityKindSchemaValidator( // Only in the case where kind and/or apiVersion have enum mismatches AND // have NO other errors, we call it a soft error. const softCandidates = validate.errors?.filter(e => - ['/kind', '/apiVersion'].includes(e.dataPath), + ['/kind', '/apiVersion'].includes(e.instancePath), ); if ( softCandidates?.length && diff --git a/packages/config-loader/src/lib/schema/compile.test.ts b/packages/config-loader/src/lib/schema/compile.test.ts index 7b7db87c8f..999dabd307 100644 --- a/packages/config-loader/src/lib/schema/compile.test.ts +++ b/packages/config-loader/src/lib/schema/compile.test.ts @@ -32,9 +32,9 @@ describe('compileConfigSchemas', () => { errors: [ { keyword: 'type', - dataPath: '/a', + instancePath: '/a', schemaPath: '#/properties/a/type', - message: 'should be string', + message: 'must be string', params: { type: 'string' }, }, ], @@ -46,9 +46,9 @@ describe('compileConfigSchemas', () => { errors: [ { keyword: 'type', - dataPath: '/b', + instancePath: '/b', schemaPath: '#/properties/b/type', - message: 'should be number', + message: 'must be number', params: { type: 'number' }, }, ], diff --git a/packages/config-loader/src/lib/schema/compile.ts b/packages/config-loader/src/lib/schema/compile.ts index b7f705751e..c1059a28ae 100644 --- a/packages/config-loader/src/lib/schema/compile.ts +++ b/packages/config-loader/src/lib/schema/compile.ts @@ -57,11 +57,11 @@ export function compileConfigSchemas( }, compile(visibility: ConfigVisibility) { return (_data, context) => { - if (context?.dataPath === undefined) { + if (context?.instancePath === undefined) { return false; } if (visibility && visibility !== 'backend') { - const normalizedPath = context.dataPath.replace( + const normalizedPath = context.instancePath.replace( /\['?(.*?)'?\]/g, (_, segment) => `/${segment}`, ); @@ -77,10 +77,10 @@ export function compileConfigSchemas( metaSchema: { type: 'string' }, compile(deprecationDescription: string) { return (_data, context) => { - if (context?.dataPath === undefined) { + if (context?.instancePath === undefined) { return false; } - const normalizedPath = context.dataPath.replace( + const normalizedPath = context.instancePath.replace( /\['?(.*?)'?\]/g, (_, segment) => `/${segment}`, ); diff --git a/packages/config-loader/src/lib/schema/filtering.test.ts b/packages/config-loader/src/lib/schema/filtering.test.ts index df06975c9f..3a5de7e2c0 100644 --- a/packages/config-loader/src/lib/schema/filtering.test.ts +++ b/packages/config-loader/src/lib/schema/filtering.test.ts @@ -244,21 +244,21 @@ describe('filterErrorsByVisibility', () => { const errors = [ { keyword: 'something', - dataPath: '/a', + instancePath: '/a', schemaPath: '#/properties/a/something', params: {}, message: 'a', }, { keyword: 'something', - dataPath: '/b', + instancePath: '/b', schemaPath: '#/properties/b/something', params: {}, message: 'b', }, { keyword: 'something', - dataPath: '/c', + instancePath: '/c', schemaPath: '#/properties/c/something', params: {}, message: 'c', @@ -314,35 +314,35 @@ describe('filterErrorsByVisibility', () => { const errors = [ { keyword: 'type', - dataPath: '/a', + instancePath: '/a', schemaPath: '#/properties/a/type', params: { type: 'number' }, message: 'a', }, { keyword: 'type', - dataPath: '/b', + instancePath: '/b', schemaPath: '#/properties/b/type', params: { type: 'string' }, message: 'b', }, { keyword: 'type', - dataPath: '/c', + instancePath: '/c', schemaPath: '#/properties/c/type', params: { type: 'array' }, message: 'c', }, { keyword: 'type', - dataPath: '/c', + instancePath: '/c', schemaPath: '#/properties/c/type', params: { type: 'object' }, message: 'd', }, { keyword: 'type', - dataPath: '/c', + instancePath: '/c', schemaPath: '#/properties/c/type', params: { type: 'null' }, message: 'e', @@ -373,21 +373,21 @@ describe('filterErrorsByVisibility', () => { const errors = [ { keyword: 'required', - dataPath: '/a', + instancePath: '/a', schemaPath: '#/properties/o/required', params: { missingProperty: 'a' }, message: 'a', }, { keyword: 'required', - dataPath: '/b', + instancePath: '/b', schemaPath: '#/properties/o/required', params: { missingProperty: 'b' }, message: 'b', }, { keyword: 'required', - dataPath: '/c', + instancePath: '/c', schemaPath: '#/properties/o/required', params: { missingProperty: 'c' }, message: 'c', diff --git a/packages/config-loader/src/lib/schema/filtering.ts b/packages/config-loader/src/lib/schema/filtering.ts index 2855979b1f..e9a0327e06 100644 --- a/packages/config-loader/src/lib/schema/filtering.ts +++ b/packages/config-loader/src/lib/schema/filtering.ts @@ -173,7 +173,7 @@ export function filterErrorsByVisibility( } const vis = - visibilityByDataPath.get(error.dataPath) ?? DEFAULT_CONFIG_VISIBILITY; + visibilityByDataPath.get(error.instancePath) ?? DEFAULT_CONFIG_VISIBILITY; return vis && includeVisibilities.includes(vis); }); } diff --git a/packages/config-loader/src/lib/schema/load.test.ts b/packages/config-loader/src/lib/schema/load.test.ts index 8510ccb1d8..41971f7d01 100644 --- a/packages/config-loader/src/lib/schema/load.test.ts +++ b/packages/config-loader/src/lib/schema/load.test.ts @@ -105,7 +105,7 @@ describe('loadConfigSchema', () => { expect(() => schema2.process([...configs, { data: { key1: 3 }, context: 'test2' }]), ).toThrow( - 'Config validation failed, Config should be string { type=string } at /key1', + 'Config validation failed, Config must be string { type=string } at /key1', ); await expect( @@ -142,7 +142,7 @@ describe('loadConfigSchema', () => { ]; expect(() => schema.process(configs)).toThrow( - 'Config validation failed, Config should be number { type=number } at /key2', + 'Config validation failed, Config must be number { type=number } at /key2', ); expect(schema.process(configs, { visibility: ['frontend'] })).toEqual([ { @@ -151,7 +151,7 @@ describe('loadConfigSchema', () => { }, ]); expect(() => schema.process(configs, { visibility: ['secret'] })).toThrow( - 'Config validation failed, Config should be number { type=number } at /key2', + 'Config validation failed, Config must be number { type=number } at /key2', ); }); @@ -203,12 +203,12 @@ describe('loadConfigSchema', () => { }, ]); expect(() => schema.process(mkConfig({ y: 1 }))).toThrow( - 'Config validation failed, Config should be string { type=string } at /nested/0/y', + 'Config validation failed, Config must be string { type=string } at /nested/0/y', ); expect(() => schema.process(mkConfig({ y: 1 }), { visibility: ['frontend'] }), ).toThrow( - 'Config validation failed, Config should be string { type=string } at /nested/0/y', + 'Config validation failed, Config must be string { type=string } at /nested/0/y', ); expect( schema.process(mkConfig({ x: 'a' }), { visibility: ['frontend'] }), @@ -229,7 +229,7 @@ describe('loadConfigSchema', () => { expect(() => schema.process(mkConfig({ y: 'aaaa' }), { visibility: ['frontend'] }), ).toThrow( - 'Config validation failed, Config should match pattern "^...$" { pattern=^...$ } at /nested/0/y', + 'Config validation failed, Config must match pattern "^...$" { pattern=^...$ } at /nested/0/y', ); // This is a bit of an edge case where we have a structural error, these should always be reported @@ -238,7 +238,7 @@ describe('loadConfigSchema', () => { visibility: ['frontend'], }), ).toThrow( - 'Config validation failed, Config should be array { type=array } at /nested', + 'Config validation failed, Config must be array { type=array } at /nested', ); }); }); @@ -273,7 +273,7 @@ describe('loadConfigSchema', () => { visibility: ['frontend'], }), ).toThrow( - "Config should have required property 'x a' { missingProperty=x a } at /other", + "Config must have required property 'x a' { missingProperty=x a } at /other", ); }); }); diff --git a/packages/config-loader/src/lib/schema/load.ts b/packages/config-loader/src/lib/schema/load.ts index aa7ed06305..959b438371 100644 --- a/packages/config-loader/src/lib/schema/load.ts +++ b/packages/config-loader/src/lib/schema/load.ts @@ -41,11 +41,11 @@ export type LoadConfigSchemaOptions = }; function errorsToError(errors: ValidationError[]): Error { - const messages = errors.map(({ dataPath, message, params }) => { + const messages = errors.map(({ instancePath, message, params }) => { const paramStr = Object.entries(params) .map(([name, value]) => `${name}=${value}`) .join(' '); - return `Config ${message || ''} { ${paramStr} } at ${dataPath}`; + return `Config ${message || ''} { ${paramStr} } at ${instancePath}`; }); const error = new Error(`Config validation failed, ${messages.join('; ')}`); (error as any).messages = messages; diff --git a/packages/config-loader/src/lib/schema/types.ts b/packages/config-loader/src/lib/schema/types.ts index 75993b3c78..cc62192e30 100644 --- a/packages/config-loader/src/lib/schema/types.ts +++ b/packages/config-loader/src/lib/schema/types.ts @@ -53,7 +53,7 @@ export const DEFAULT_CONFIG_VISIBILITY: ConfigVisibility = 'backend'; */ export type ValidationError = { keyword: string; - dataPath: string; + instancePath: string; schemaPath: string; params: Record; propertyName?: string;