Skip to content

Commit 24f76cc

Browse files
committed
address PR review comments for prompt path handling
- Treat path traversal as hard failure: return blocked=true with empty resolvedPath instead of leaking the outside-root absolute path - Handle file:// URIs in resolvePromptFilePath via fileURLToPath so all callers (queryPath, workspaceUri, etc.) get consistent URI handling - Replace synchronous existsSync with async fs/promises.access to avoid blocking the event loop on the prompt hot path - Fix integration test success condition to fail when no tests executed - Make VS Code e2e invalid-language test deterministic (assert inline validation instead of accepting both throw and inline error) - Fix misleading test name "should return the original path" to match actual behavior (resolves relative to workspace root)
1 parent e07ae1b commit 24f76cc

File tree

6 files changed

+158
-132
lines changed

6 files changed

+158
-132
lines changed

client/src/lib/integration-test-runner.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,15 @@ export class IntegrationTestRunner {
246246
);
247247
}
248248

249-
return (
250-
(totalIntegrationTests > 0 || workflowIntegrationSucceeded || promptIntegrationSucceeded) &&
251-
workflowIntegrationSucceeded &&
252-
promptIntegrationSucceeded
253-
);
249+
if (totalIntegrationTests === 0) {
250+
this.logger.log(
251+
"No integration tests were executed across tool, workflow, or prompt suites.",
252+
"ERROR"
253+
);
254+
return false;
255+
}
256+
257+
return workflowIntegrationSucceeded && promptIntegrationSucceeded;
254258
} catch (error) {
255259
this.logger.log(`Error running integration tests: ${error.message}`, "ERROR");
256260
return false;

extensions/vscode/test/suite/mcp-prompt-e2e.integration.test.ts

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -177,34 +177,26 @@ suite('MCP Prompt Error Handling Integration Tests', () => {
177177
this.timeout(15_000);
178178

179179
// VS Code slash command might let a user type an invalid language value.
180-
// The server should return a helpful error message rather than a raw
181-
// MCP protocol error (-32602).
182-
try {
183-
const result = await client.getPrompt({
184-
name: 'explain_codeql_query',
185-
arguments: {
186-
queryPath: '/some/query.ql',
187-
language: 'rust',
188-
},
189-
});
180+
// The server should return a helpful inline validation message rather than
181+
// a raw MCP protocol error (-32602), and client.getPrompt() should not throw.
182+
const result = await client.getPrompt({
183+
name: 'explain_codeql_query',
184+
arguments: {
185+
queryPath: '/some/query.ql',
186+
language: 'rust',
187+
},
188+
});
190189

191-
// If the server returns messages instead of throwing, the error info
192-
// should be embedded in the response text.
193-
const text = getFirstMessageText(result);
194-
assert.ok(
195-
text.includes('Invalid') || text.includes('invalid') || text.includes('not supported'),
196-
`Response should indicate the language is invalid. Got:\n${text.slice(0, 500)}`,
197-
);
198-
console.log('[mcp-prompt-e2e] explain_codeql_query returned inline error for invalid language');
199-
} catch (error: unknown) {
200-
// If the SDK throws, verify the error message is user-friendly.
201-
const msg = error instanceof Error ? error.message : String(error);
202-
assert.ok(
203-
msg.includes('Invalid') || msg.includes('invalid') || msg.includes('language'),
204-
`Error should mention invalid argument. Got: ${msg.slice(0, 500)}`,
205-
);
206-
console.log(`[mcp-prompt-e2e] explain_codeql_query threw for invalid language: ${msg.slice(0, 200)}`);
207-
}
190+
const text = getFirstMessageText(result);
191+
192+
// The error info should be embedded in the response text, including clear
193+
// indication that the input was invalid and what options are allowed.
194+
assert.ok(
195+
text.includes('Invalid input for') && text.includes('javascript'),
196+
`Response should indicate the language is invalid and show allowed options. Got:\n${text.slice(0, 500)}`,
197+
);
198+
199+
console.log('[mcp-prompt-e2e] explain_codeql_query returned inline validation error for invalid language');
208200
});
209201

210202
// ─────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)