{"record":{"id":"8e850e7c66dff4de","repo":"risingwavelabs/risingwave","slug":"invalid-pgvector-dimension-in-type-type-name","errorCode":null,"errorMessage":"invalid pgvector dimension in type `{type_name}`","messagePattern":"invalid pgvector dimension in type `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/connector_common/postgres.rs","lineNumber":757,"sourceCode":"    Ok(dtype)\n}\n\nfn parse_pgvector_dimension(type_name: &str) -> ConnectorResult<Option<usize>> {\n    let normalized = type_name.trim().to_ascii_lowercase();\n    if normalized == \"vector\" {\n        bail!(\"pgvector type `vector` is missing dimension, expected `vector(n)`\")\n    }\n    if !normalized.starts_with(\"vector(\") || !normalized.ends_with(')') {\n        return Ok(None);\n    }\n\n    let dim_text = normalized\n        .trim_start_matches(\"vector(\")\n        .trim_end_matches(')')\n        .trim();\n    let dim = dim_text\n        .parse::<usize>()\n        .map_err(|_| anyhow!(\"invalid pgvector dimension in type `{type_name}`\"))?;\n\n    if !(1..=DataType::VEC_MAX_SIZE).contains(&dim) {\n        bail!(\n            \"pgvector dimension out of range in type `{}`: expect 1..={}\",\n            type_name,\n            DataType::VEC_MAX_SIZE\n        );\n    }\n\n    Ok(Some(dim))\n}\n\n// Used for sink connector\n// We use `sea-schema` for table schema discovery.\n// So we have to map `sea-schema` pg types\n// to `tokio-postgres` pg types (which we use for query binding).\nfn sea_type_to_pg_type(sea_type: &SeaType) -> ConnectorResult<tokio_postgres::types::Type> {\n    use tokio_postgres::types::Type as PgType;","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/connector_common/postgres.rs#L739-L775","documentation":"For pgvector types of the form `vector(n)`, the dimension text must parse as a `usize`. `parse_pgvector_dimension` throws 'invalid pgvector dimension in type `{type_name}`' when the content inside parentheses is not a valid unsigned integer.","triggerScenarios":"`parse_pgvector_dimension` receiving a type name matching `vector(...)` whose inner text fails `parse::<usize>()` — e.g. `vector()`, `vector(abc)`, `vector(1.5)`, `vector(-4)`.","commonSituations":"Corrupted or hand-edited type metadata; typenames synthesized by tooling rather than real pgvector types; unusual whitespace or characters inside the parentheses.","solutions":["Ensure the upstream column type is a real pgvector type like `vector(768)`","Inspect the actual column type with `SELECT atttypmod FROM pg_attribute WHERE attrelid=... AND attname=...;` and re-discover the schema","Fix any tooling that rewrites/normalizes type names before they reach RisingWave"],"exampleFix":"-- before (malformed)\nCREATE TABLE t (v vector());\n-- after\nCREATE TABLE t (v vector(768));","handlingStrategy":"validation","validationCode":"fn validate_vector_dim_text(type_name: &str) -> Result<(), String> {\n    let inner = type_name.trim_start_matches(\"vector(\").trim_end_matches(')').trim();\n    inner.parse::<usize>().map(|_| ()).map_err(|_| format!(\"bad dimension in {type_name}\"))\n}","typeGuard":"fn is_well_formed_vector_type(s: &str) -> bool {\n    let s = s.trim().to_ascii_lowercase();\n    s.starts_with(\"vector(\") && s.ends_with(')')\n        && s[\"vector(\".len()..s.len()-1].trim().parse::<usize>().is_ok()\n}","tryCatchPattern":"match setup_result {\n    Err(e) if e.to_string().contains(\"invalid pgvector dimension\") => {\n        log::warn!(\"type metadata malformed: {e}; re-run schema discovery\");\n        Err(CdcError::SchemaMetadataCorrupt(e))\n    }\n    other => other,\n}","preventionTips":["Let pgvector create the type (typed column) instead of synthesizing type names in tooling","Re-run schema discovery if type metadata looks hand-edited","Sanitize type names before passing them to the connector"],"tags":["postgres","pgvector","vector","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}