{"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/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/commands/ruvector/pg-utils.ts#L25-L47","documentation":"validateTimestamp() in ruvector/pg-utils.ts accepts only ISO 8601 timestamps (YYYY-MM-DD[T ]HH:MM:SS with optional fractional seconds and optional Z/±HH:MM zone) so values can be embedded in SQL without quoting risk. Epoch numbers, slash-formatted dates, locale strings, and Date.prototype.toString() output all fail the regex.","triggerScenarios":"Passing 1712345678 (epoch seconds), '2026/08/18 10:00:00' (slashes), 'Tue Aug 18 2026 10:00:00 GMT+0000' (Date.toString()), or a date-only value '2026-08-18' with no time component.","commonSituations":"Feeding timestamps exported from databases in locale format; forgetting to call .toISOString() on a Date; producers emitting RFC 2822 or unix time.","solutions":["Convert in JS before passing: new Date(value).toISOString() always satisfies the regex","Have the producer emit 'YYYY-MM-DDTHH:MM:SS.sssZ' (toISOString format)","If you only have a calendar date, append T00:00:00Z to make it valid"],"exampleFix":"// before\nconst ts = new Date().toString(); // 'Tue Aug 18 2026 ...'\n\n// after\nconst ts = new Date().toISOString(); // '2026-08-18T10:00:00.000Z'","handlingStrategy":"validation","validationCode":"const ISO_RE = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:?\\d{2})?$/;\nconst ts = ISO_RE.test(value) ? value : new Date(value).toISOString();\nawait runImport({ timestamp: ts });","typeGuard":"function isIso8601Timestamp(v: unknown): v is string {\n  return typeof v === 'string' && /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:?\\d{2})?$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Always emit timestamps via Date.prototype.toISOString() at the producer","Reject epoch numbers and locale strings at your system boundary","A date-only value is not enough — append T00:00:00Z when no time exists"],"tags":["database","postgresql","timestamp","iso8601","validation"],"backgroundTag":"invalid-timestamp-format","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"}