{"record":{"id":"75496f0ed49a86b3","repo":"ruvnet/ruflo","slug":"schema-name-must-not-be-empty","errorCode":null,"errorMessage":"Schema name must not be empty","messagePattern":"Schema name must not be empty","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts","lineNumber":22,"sourceCode":" *\n * @module v3/cli/commands/ruvector/pg-utils\n */\n\n/**\n * Valid PostgreSQL identifier pattern.\n * Allows only ASCII letters, digits, and underscores.\n * Must start with a letter or underscore.\n */\nconst VALID_PG_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * Validate a PostgreSQL schema name.\n * Throws if the name contains characters that could enable SQL injection.\n * Safe names are returned as-is (no quoting needed since they match the identifier pattern).\n */\nexport function validateSchemaName(schema: string): string {\n  if (!schema || schema.length === 0) {\n    throw new Error('Schema name must not be empty');\n  }\n  if (schema.length > 63) {\n    throw new Error(`Schema name too long (${schema.length} chars, max 63): \"${schema}\"`);\n  }\n  if (!VALID_PG_IDENTIFIER.test(schema)) {\n    throw new Error(\n      `Invalid schema name: \"${schema}\". Must contain only letters, digits, and underscores, and start with a letter or underscore.`\n    );\n  }\n  return schema;\n}\n\n/**\n * Validate a PostgreSQL timestamp string.\n * Only allows ISO 8601 format to prevent SQL injection via timestamp fields.\n */\nconst VALID_TIMESTAMP = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:?\\d{2})?$/;\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts#L4-L40","documentation":"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.","triggerScenarios":"Passing --schema '' (or an empty string from String() coercion of a missing/undefined flag value) to any ruvector command that accepts a schema.","commonSituations":"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.","solutions":["Provide a concrete schema name, e.g. --schema claude_flow","Check the environment variable / config key that supplies the schema is actually set and non-empty","In wrappers, default the value before invoking: SCHEMA=\"${SCHEMA:-claude_flow}\""],"exampleFix":"# before\nSCHEMA=\"\" ruflo ruvector ... --schema \"$SCHEMA\"\n\n# after\nSCHEMA=\"${SCHEMA:-claude_flow}\" ruflo ruvector ... --schema \"$SCHEMA\"","handlingStrategy":"validation","validationCode":"function orDefaultSchema(v: string | undefined): string {\n  return v && v.length > 0 ? v : 'claude_flow';\n}\nawait runRuvector(['--schema', orDefaultSchema(schema)]);","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Default the schema option in wrappers: SCHEMA=\"${SCHEMA:-claude_flow}\"","Fail loudly in CI when configuration env vars are unset instead of passing empty strings","Treat empty schema as misconfiguration, not a wildcard"],"tags":["database","postgresql","schema","validation"],"backgroundTag":"empty-required-parameter","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}