From 430b8978402961929506df10fbff31a5469eff72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 20 Feb 2026 12:14:08 +0100 Subject: [PATCH] add explicit clear rejection of MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../request/applyPredicateEntityFilterToQuery.test.ts | 6 ++++++ .../service/request/applyPredicateEntityFilterToQuery.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.test.ts b/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.test.ts index 70d5461c3a..b90e0ca409 100644 --- a/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.test.ts +++ b/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.test.ts @@ -231,6 +231,12 @@ describe.each(databases.eachSupportedId())( ).resolves.toEqual(['service-a', 'website-c']); }); + it('throws on $contains operator', async () => { + await expect( + query({ 'metadata.name': { $contains: 'service' } as any }), + ).rejects.toThrow(/\$contains operator is not supported/); + }); + it('throws on top-level primitive', async () => { await expect(query('bad-value' as any)).rejects.toThrow( /top-level primitive values are not supported/, diff --git a/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.ts b/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.ts index 2a404b88bf..56d85a9da1 100644 --- a/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.ts +++ b/plugins/catalog-backend/src/service/request/applyPredicateEntityFilterToQuery.ts @@ -209,6 +209,11 @@ function applyFieldCondition(options: { .andWhereRaw('?? like ? escape ?', ['value', `${escaped}%`, '\\']); return targetQuery.andWhere(onEntityIdField, 'in', matchQuery); } + + if ('$contains' in value) { + // TODO(freben): Implement this, AT LEAST for some special cases such as tags and relations. + throw new InputError('The $contains operator is not supported'); + } } throw new InputError(