Skip to content

fix(server): read a package data file whose name has a space - #1445

Draft
jswir wants to merge 1 commit into
mainfrom
jswir/quote-data-file-paths
Draft

jswir wants to merge 1 commit into
mainfrom
jswir/quote-data-file-paths

Conversation

@jswir

@jswir jswir commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

A package data file whose name has a space, such as data/Revenue by month.csv, now lists with its columns and row count. Before, it listed as unreadable.

Why it broke

To list a package's data files, getDatabaseInfo compiles duckdb.table('<path>') for each one. Malloy's DuckDB table-path check takes a bare path only when every character is in a short safe set, and a space is not in it. So the compile failed with:

Invalid DuckDB table path: ".../data/Revenue by month.csv" — expected an identifier path, a quoted identifier path, a single-quoted literal ('foo.csv'), or a simple file/URL path (some file/URL paths require quoting).

readDatabases caught that and listed the file with error and no info. A name with an apostrophe failed the same way.

The change

getDatabaseInfo now passes the path as a single-quoted DuckDB literal ('...', with ' doubled), which is the form the check asks for. For a path the check already accepted, the literal compiles to the same SQL as before. The literal sits inside a Malloy double-quoted string, so \ and " are escaped for that string.

File Before After
data/Revenue by month.csv error: Invalid DuckDB table path info: 2 columns, 3 rows
data/Bob's sales.csv error: Invalid DuckDB table path info: 2 columns, 3 rows
database.csv info info (unchanged)

One case is still refused. Malloy's single-quoted form refuses a path containing ; or --, and on current main a bare path containing -- is refused too. So a package whose absolute directory contains -- still lists every data file as unreadable. That is true before and after this change. I found it because my checkout path contained --, which failed the existing getDatabaseInfo tests on unmodified main.

Testing

A new case in package.spec.ts probes two real CSV files against real DuckDB, one named with a space and one with an apostrophe.

bun test --timeout 100000 src/service/package.spec.ts
  • Without the fix: 23 pass, 1 fail. The new case fails with Invalid DuckDB table path: "/.../testPackage/data/Revenue by month.csv".
  • With the fix: 24 pass, 0 fail.

bun run lint and prettier --check pass on the touched files.

🤖 Generated with Claude Code

Signed-off-by: James Swirhun <james@credibledata.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant