fix(cli): make connection-not-configured errors actionable and expected (#301)

The MCP sql_execution/sl_query tools and the `ktx sql` CLI threw a plain Error naming no valid connection ids when an agent passed an unconfigured connectionId (or omitted it with multiple connections). The message reached the agent verbatim but gave it nothing to correct with, so it re-guessed for days, and each correct caller-driven rejection filed in PostHog Error Tracking as a ktx fault (issue 019eb10c, 8 occurrences on one install).

Add a shared resolver (resolveConfiguredConnection / resolveRequiredConnectionId) that throws KtxExpectedError listing the configured connections, and route the three SQL-execution call sites through it. Expected-error classification keeps these out of Error Tracking while the actionable message lets agents self-correct.
This commit is contained in:
Andrey Avtomonov 2026-06-15 14:38:44 +02:00 committed by GitHub
parent 9587049283
commit 8a50601582
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 189 additions and 20 deletions

View file

@ -306,7 +306,9 @@ describe('runKtxSql', () => {
),
).resolves.toBe(1);
expect(io.stderr()).toContain('Connection "warehouse" is not configured in ktx.yaml');
expect(io.stderr()).toContain(
'Connection "warehouse" is not configured in ktx.yaml. No connections are configured in ktx.yaml.',
);
});
it('rejects connectors without read-only SQL support and still cleans up', async () => {