ruvnet/ruflo · error · Error
Schema name too long
Error message
Schema name too long (${schema.length} chars, max 63): "${schema}" What it means
PostgreSQL truncates identifiers to 63 bytes (NAMEDATALEN-1); validateSchemaName() enforces this client-side so an over-long schema name is rejected instead of being silently truncated by the server — silent truncation would break subsequent lookups and grants.
Solutions
- Shorten the schema to at most 63 characters — abbreviate segments
- Derive a deterministic compact name: hash the long identifier and keep a short prefix, e.g. tenant_a1b2c3d4
- Enforce the limit where the name is generated, not where it is consumed
Example fix
// before
const schema = `tenant_${orgName}_${deploymentId}`; // 71 chars
// after
const crypto = require('node:crypto');
const h = crypto.createHash('sha256').update(`${orgName}/${deploymentId}`).digest('hex').slice(0, 8);
const schema = `tenant_${h}`; // 15 chars Defensive patterns
Strategy: validation
Validate before calling
function assertSchemaLength(schema: string): void {
if (schema.length > 63) throw new Error(`schema exceeds PostgreSQL's 63-char limit (${schema.length})`);
}
assertSchemaLength(schema); // enforce where the name is generated Prevention
- Cap generated schema names at 63 characters at the generation site
- Use short deterministic hashes instead of concatenating long identifiers
- Remember the limit is bytes, not characters, for non-ASCII names
When it happens
Trigger: Passing a schema derived from a long project/org/tenant string that exceeds 63 characters, e.g. tenant_<uuid>_<hash> concatenations.
Common situations: Auto-generating schema names from multi-part identifiers; embedding full kebab-case project names plus UUIDs into the schema component.
Related errors
- Invalid schema name: " ". Must contain only letters…
- Schema name must not be empty
- Invalid embedding value at index
- Invalid timestamp format
- agent must be an object
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/e1f173968e25ee5e.
Report an issue: GitHub.
Appendix: source
Thrown at v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts:25
/**
* 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})?$/;
export function validateTimestamp(value: string): string {
if (!VALID_TIMESTAMP.test(value)) {
throw new Error(`Invalid timestamp format: "${value}". Expected ISO 8601.`);View on GitHub (pinned to fa13ee4ad6)