Skip to content

Unrecognized Postgres types silently coerce to String #3175

@atharvalade

Description

@atharvalade

The default branch in extract_column_value_static attempts to read any unrecognized Postgres type as Option<String>:

_ => {
    let value: Option<String> = row
        .try_get(column_index)
        .map_err(|_| Error::InvalidRecord)?;
    Ok(value
        .map(serde_json::Value::String)
        .unwrap_or(serde_json::Value::Null))
}

If the type cannot be deserialized as String (arrays, composite types, ranges, etc.), it returns Error::InvalidRecord with no indication of which column or type caused the failure. There are many common Postgres types not covered: arrays (_INT4, _TEXT), enums, INTERVAL, INET,CIDR, MACADDR, TSVECTOR, POINT, JSONPATH, etc.

Fix: Log the type name and column name before falling through to the default. Consider using row.try_get_raw() and converting to a text representation as a more robust fallback. At minimum: warn!("Unknown column type '{}' for column '{}', attempting String fallback", type_name, column.name());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions