From 737da234f6be010c0fba50bfe270db7498aff100 Mon Sep 17 00:00:00 2001 From: patel0700 Date: Wed, 24 Dec 2025 03:46:56 -0600 Subject: [PATCH] fix: validate channel parameters when address is empty --- package-lock.json | 12 ---------- .../ruleset/v2/functions/channelParameters.ts | 16 +++++++++++--- packages/parser/test/old-api/tag.spec.ts | 10 ++++----- .../v2/asyncapi2-channel-parameters.spec.ts | 22 +++++++++++++++++++ 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3b1a2b808..0e4c99e2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1941,18 +1941,6 @@ "@types/node": "*" } }, - "node_modules/@types/eslint": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.0.tgz", - "integrity": "sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", diff --git a/packages/parser/src/ruleset/v2/functions/channelParameters.ts b/packages/parser/src/ruleset/v2/functions/channelParameters.ts index d9d89b548..16716a32e 100644 --- a/packages/parser/src/ruleset/v2/functions/channelParameters.ts +++ b/packages/parser/src/ruleset/v2/functions/channelParameters.ts @@ -18,10 +18,20 @@ export const channelParameters = createRulesetFunction<{ parameters: Record { - const path = ctx.path[ctx.path.length - 1] as string; const results: IFunctionResult[] = []; - const parameters = parseUrlVariables(path); + // Channel address is the key under `channels` + const channelAddress = ctx.path[ctx.path.length - 1]; + + if (typeof channelAddress !== 'string' || channelAddress.trim().length === 0) { + results.push({ + message: 'Channel address must be a non-empty string when "parameters" are provided.', + path: [...ctx.path], + }); + return results; + } + + const parameters = parseUrlVariables(channelAddress); if (parameters.length === 0) return; const missingParameters = getMissingProps(parameters, targetVal.parameters); @@ -46,4 +56,4 @@ export const channelParameters = createRulesetFunction<{ parameters: Record