Skip to content

Commit b8f3c87

Browse files
mrdailey99claude
andcommitted
fix(mcp): address PR 121 review comments
- filterTestRunOutput: split on /\r?\n/ and strip trailing \r so Windows CRLF output does not leave stray \r chars or break noise pattern matching (Copilot suggestion) - rcaTools run_index schema: add .int().positive() validation on both provar.testrun.report.locate and provar.testrun.rca to reject run_index <= 0 before it reaches resolveResultsLocation (Copilot suggestion) - test: add CRLF-safety test for filterTestRunOutput Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6a10625 commit b8f3c87

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/mcp/tools/automationTools.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ const NOISE_PATTERNS: RegExp[] = [
177177
* Returns the filtered text and the count of suppressed lines.
178178
*/
179179
export function filterTestRunOutput(raw: string): { filtered: string; suppressed: number } {
180-
const lines = raw.split('\n');
180+
const lines = raw.split(/\r?\n/);
181181
const kept: string[] = [];
182182
let suppressed = 0;
183183
let lastKeptWasBlank = false;
184184

185-
for (const line of lines) {
185+
for (const rawLine of lines) {
186+
const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;
186187
if (NOISE_PATTERNS.some((p) => p.test(line))) {
187188
suppressed++;
188189
continue;

src/mcp/tools/rcaTools.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,10 @@ export function registerTestRunLocate(server: McpServer): void {
401401
.describe('Explicit override for the results base directory; if provided, skip auto-detection'),
402402
run_index: z
403403
.number()
404+
.int()
405+
.positive()
404406
.optional()
405-
.describe('Which Increment run to target (default: latest)'),
407+
.describe('Which Increment run to target (default: latest); must be a positive integer'),
406408
},
407409
(input) => {
408410
const requestId = makeRequestId();
@@ -668,8 +670,10 @@ export function registerTestRunRca(server: McpServer): void {
668670
.describe('Explicit override for the results base directory'),
669671
run_index: z
670672
.number()
673+
.int()
674+
.positive()
671675
.optional()
672-
.describe('Which Increment run to target (default: latest)'),
676+
.describe('Which Increment run to target (default: latest); must be a positive integer'),
673677
locate_only: z
674678
.boolean()
675679
.optional()

test/unit/mcp/automationTools.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,5 +635,14 @@ describe('filterTestRunOutput', () => {
635635
assert.ok(filtered.includes('line1'), 'Content should be preserved');
636636
assert.ok(filtered.includes('line2'), 'Content should be preserved');
637637
});
638+
639+
it('handles Windows CRLF line endings without leaving trailing \\r', () => {
640+
const raw = 'INFO Starting\r\ncom.networknt.schema.JsonSchemaFactory - loaded\r\nINFO Done\r\n';
641+
const { filtered, suppressed } = filterTestRunOutput(raw);
642+
assert.equal(suppressed, 1, 'CRLF noise line should be suppressed');
643+
assert.ok(!filtered.includes('\r'), 'No trailing \\r should remain in output');
644+
assert.ok(filtered.includes('INFO Starting'), 'Real output should remain');
645+
assert.ok(filtered.includes('INFO Done'), 'Real output should remain');
646+
});
638647
});
639648

0 commit comments

Comments
 (0)