Skip to content

Commit 654a758

Browse files
subsetparkclaude
andcommitted
sqlite3: guard empty token list in translateDotCommand
The destructured `head` is typed `string` but is actually `string | undefined` if `tokens` is empty (TypeScript's index-signature inference hides this). The caller's `/^\.[a-zA-Z]/` guard means tokens is always non-empty in practice, but add an explicit check so a future caller change can't surface as a confusing "unknown command: undefined" error from the switch's default branch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6ae1657 commit 654a758

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/just-bash/src/commands/sqlite3/dot-commands.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ async function translateDotCommand(
143143
): Promise<{ sql: string; quit?: true } | { error: string }> {
144144
const [head, ...rest] = tokens;
145145

146+
// The caller's guard (`/^\.[a-zA-Z]/`) ensures non-empty tokens in
147+
// practice, but make the assumption explicit so a future caller change
148+
// can't produce confusing "unknown command: undefined" errors.
149+
if (!head) {
150+
return { error: "Error: empty dot-command" };
151+
}
152+
146153
if (UNSUPPORTED_DOT_COMMANDS.has(head)) {
147154
return {
148155
error: `Error: ${head} is not supported by just-bash sqlite3`,

0 commit comments

Comments
 (0)