{"record":{"id":"997d45c2e48003e8","repo":"ruvnet/ruflo","slug":"invalid-timestamp-format-value-expected-iso","errorCode":null,"errorMessage":"Invalid timestamp format: \"${value}\". Expected ISO 8601.","messagePattern":"Invalid timestamp format: \"(.+?)\"\\. Expected ISO 8601\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts","lineNumber":43,"sourceCode":"    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\nexport function validateTimestamp(value: string): string {\n  if (!VALID_TIMESTAMP.test(value)) {\n    throw new Error(`Invalid timestamp format: \"${value}\". Expected ISO 8601.`);\n  }\n  return value;\n}\n","sourceCodeStart":25,"sourceCodeEnd":47,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts#L25-L47","documentation":"Thrown by validateTimestamp() when the value fails the ISO-8601 regex VALID_TIMESTAMP. Timestamps are interpolated into SQL, so only the strict ISO grammar is accepted to prevent injection via timestamp fields; loose date strings or locale-formatted times are rejected.","triggerScenarios":"Passing a timestamp like '2024/08/12', 'Aug 12 2024', '2024-08-12' (date-only, no time component — the regex requires a time), epoch numbers coerced to string, or values with embedded SQL.","commonSituations":"Locale-formatted dates from spreadsheets/log exports, date-only values where the column expects a timestamp, epoch seconds passed as a string, or non-UTC offsets in unusual formats.","solutions":["Emit timestamps via `new Date(...).toISOString()` which always yields the accepted form.","If you have a date-only, append 'T00:00:00Z' before validating.","If you have an epoch, convert with `new Date(epochMs).toISOString()`."],"exampleFix":"// before\nvalidateTimestamp('2024-08-12')\n// after\nvalidateTimestamp(new Date('2024-08-12').toISOString()) // 2024-08-12T00:00:00.000Z","handlingStrategy":"validation","validationCode":"function toIsoTimestamp(v: string | number | Date): string {\n  const iso = new Date(v).toISOString();\n  // re-validate to satisfy the strict regex\n  return validateTimestamp(iso);\n}","typeGuard":"const ISO_8601 = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:?\\d{2})?$/;\nconst isIsoTimestamp = (v: unknown): v is string =>\n  typeof v === 'string' && ISO_8601.test(v);","tryCatchPattern":"try {\n  validateTimestamp(value);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.startsWith('Invalid timestamp format')) {\n    value = new Date(value).toISOString(); // normalize once\n  } else throw e;\n}","preventionTips":["Always emit timestamps via Date.prototype.toISOString().","Append 'T00:00:00Z' to date-only values.","Never pass locale-formatted or epoch-as-string timestamps."],"tags":["validation","postgres","security","pg-utils","timestamp"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}