Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/templates/integrations/neon/files/lib/neon-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ export async function getTableRowCount(
tableName: string,
schema: string = "public",
): Promise<number> {
if (!/^[a-zA-Z0-9_]+$/.test(schema)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow quoted PostgreSQL identifiers in row-count lookup

The new allowlist ^[a-zA-Z0-9_]+$ is stricter than PostgreSQL identifier rules and rejects valid quoted schema/table names (for example names containing -, $, spaces, or non-ASCII characters). In this template, listTables() reads table names from pg_tables and those names are then passed into getTableRowCount(), so valid tables can now throw Invalid input and lose row counts in list-tables/describe-table despite being queryable. This is a functional regression introduced by the change.

Useful? React with 👍 / 👎.

throw new Error('Invalid schema name: must contain only letters, numbers, and underscores');
}
if (!/^[a-zA-Z0-9_]+$/.test(tableName)) {
throw new Error('Invalid table name: must contain only letters, numbers, and underscores');
}
const result = await query<{ count: string }>(
`SELECT COUNT(*) as count FROM "${schema}"."${tableName}"`,
);
Expand Down
Loading