ruvnet/ruflo · error · Error
Schema name must not be empty
Error message
Schema name must not be empty
What it means
Thrown by validateSchemaName() when the schema string is null, undefined, or zero-length. Empty schema names are rejected because interpolating one into SQL would produce malformed statements (`CREATE SCHEMA `) or, worse, fall through to a default schema, masking a configuration bug.
Source
Thrown at v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts:22
*
* @module v3/cli/commands/ruvector/pg-utils
*/
/**
* Valid PostgreSQL identifier pattern.
* Allows only ASCII letters, digits, and underscores.
* Must start with a letter or underscore.
*/
const VALID_PG_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
/**
* Validate a PostgreSQL schema name.
* Throws if the name contains characters that could enable SQL injection.
* Safe names are returned as-is (no quoting needed since they match the identifier pattern).
*/
export function validateSchemaName(schema: string): string {
if (!schema || schema.length === 0) {
throw new Error('Schema name must not be empty');
}
if (schema.length > 63) {
throw new Error(`Schema name too long (${schema.length} chars, max 63): "${schema}"`);
}
if (!VALID_PG_IDENTIFIER.test(schema)) {
throw new Error(
`Invalid schema name: "${schema}". Must contain only letters, digits, and underscores, and start with a letter or underscore.`
);
}
return schema;
}
/**
* Validate a PostgreSQL timestamp string.
* Only allows ISO 8601 format to prevent SQL injection via timestamp fields.
*/
const VALID_TIMESTAMP = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:?\d{2})?$/;
View on GitHub (pinned to 6b01dc5a68)
Solutions
- Provide a concrete schema name (e.g. 'public', 'ruvector', or your tenant schema).
- Check the source: if it comes from env, ensure the env var is set and non-empty.
- Default explicitly and loudly at the config layer rather than passing '' through.
Example fix
// before
validateSchemaName(process.env.PG_SCHEMA ?? '')
// after
const schema = process.env.PG_SCHEMA;
if (!schema) throw new Error('PG_SCHEMA must be set');
validateSchemaName(schema); Defensive patterns
Strategy: validation
Validate before calling
function requireSchemaName(v: string | undefined | null): string {
if (!v || v.length === 0) throw new Error('Schema name must not be empty');
return v;
} Type guard
const isNonEmptySchemaName = (v: unknown): v is string => typeof v === 'string' && v.length > 0;
Try / catch
try {
validateSchemaName(schema);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (msg === 'Schema name must not be empty') {
schema = 'public'; // or fail loudly per your policy
} else throw e;
} Prevention
- Treat an unset schema env var as a fatal config error.
- Default explicitly at the config layer; do not pass '' through.
- Fail at startup, not at the first SQL call.
When it happens
Trigger: Calling a ruvector pg helper with an empty schema string, a config value that resolved to '' (e.g. env var unset, defaulted to empty), or undefined passed where a schema name was expected.
Common situations: Environment variable for the schema name unset (so it coerces to ''), a config loader returning '' for a missing key instead of undefined, or a migration step that forgot to set the schema.
Related errors
- Invalid schema name: "${schema}". Must contain only letters,
- Invalid timestamp format: "${value}". Expected ISO 8601.
- Schema name too long (${schema.length} chars, max 63): "${sc
- Validation failed: ${result.error}
- Header JSON exceeds maximum size (${headerLen} > ${MAX_HEADE
AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12).
Data as JSON: /api/errors/75496f0ed49a86b3.
Report an issue: GitHub.