ruvnet/ruflo · error · Error

Schema name must not be empty

Error message

Schema name must not be empty

What it means

validateSchemaName() in ruvector/pg-utils.ts rejects schema names that are empty before they can reach PostgreSQL. Empty identifiers would produce broken SQL, so the check fails fast; length and character-set checks follow in subsequent guards.

Solutions

  1. Provide a concrete schema name, e.g. --schema claude_flow
  2. Check the environment variable / config key that supplies the schema is actually set and non-empty
  3. In wrappers, default the value before invoking: SCHEMA="${SCHEMA:-claude_flow}"

Example fix

# before
SCHEMA="" ruflo ruvector ... --schema "$SCHEMA"

# after
SCHEMA="${SCHEMA:-claude_flow}" ruflo ruvector ... --schema "$SCHEMA"
Defensive patterns

Strategy: validation

Validate before calling

function orDefaultSchema(v: string | undefined): string {
  return v && v.length > 0 ? v : 'claude_flow';
}
await runRuvector(['--schema', orDefaultSchema(schema)]);

Type guard

function isNonEmptyString(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0;
}

Prevention

When it happens

Trigger: Passing --schema '' (or an empty string from String() coercion of a missing/undefined flag value) to any ruvector command that accepts a schema.

Common situations: A wrapper script or env var that feeds the schema option was never set, so it expands to empty; CI pipelines exporting SCHEMA= with no value.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/75496f0ed49a86b3. Report an issue: GitHub.

Appendix: 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 fa13ee4ad6)