{"record":{"id":"585e405662eaa6d9","repo":"SeaQL/sea-orm","slug":"failed-to-get-ip-address-array","errorCode":null,"errorMessage":"Failed to get ip address array","messagePattern":"Failed to get ip address array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":672,"sourceCode":"                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Json(Some(Box::new(val))))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-ipnetwork\")]\n                        \"INET\" | \"CIDR\" => Value::IpNetwork(\n                            row.try_get::<Option<ipnetwork::IpNetwork>, _>(c.ordinal())\n                                .expect(\"Failed to get ip address\"),\n                        ),\n                        #[cfg(feature = \"with-ipnetwork\")]\n                        \"INET[]\" | \"CIDR[]\" => Value::Array(\n                            sea_query::ArrayType::IpNetwork,\n                            row.try_get::<Option<Vec<ipnetwork::IpNetwork>>, _>(c.ordinal())\n                                .expect(\"Failed to get ip address array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::IpNetwork(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-mac_address\")]\n                        \"MACADDR\" | \"MACADDR8\" => Value::MacAddress(\n                            row.try_get::<Option<mac_address::MacAddress>, _>(c.ordinal())\n                                .expect(\"Failed to get mac address\"),\n                        ),\n                        #[cfg(all(feature = \"with-mac_address\", feature = \"postgres-array\"))]\n                        \"MACADDR[]\" | \"MACADDR8[]\" => Value::Array(\n                            sea_query::ArrayType::MacAddress,\n                            row.try_get::<Option<Vec<mac_address::MacAddress>>, _>(c.ordinal())","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L654-L690","documentation":"This panic is raised when sea-orm cannot decode an INET[]/CIDR[] array column into Option<Vec<ipnetwork::IpNetwork>> (requires `with-ipnetwork`). try_get fails when the value is not a recognized inet/cidr array (e.g. it's text[]), an element type is unsupported, or the sqlx build lacks array support for these types. The `.expect` escalates to a panic during row decoding.","triggerScenarios":"Selecting an inet[] column while the actual column is text[] or the query cast it, or the `postgres-array`/`with-ipnetwork` features are inconsistently compiled between sea-orm and sqlx so the array decoder isn't present.","commonSituations":"IP allow-list tables using text[] that were later modeled as IpNetwork arrays; raw SQL with array_agg returning text[]; feature-flag drift after adding postgres-array in only some crates.","solutions":["Check the real type with `SELECT pg_typeof(col)` and cast explicitly: `SELECT col::inet[] FROM t`.","Migrate text[] columns storing IPs to inet[]: `ALTER TABLE t ALTER col TYPE inet[] USING col::inet[]`.","Enable `with-ipnetwork` and `postgres-array` together on sea-orm in all workspace crates.","Update sqlx/sea-orm if the inet array element type is not supported in your pinned versions."],"exampleFix":"// before\nSELECT allowlist FROM firewall; -- allowlist is text[]\n\n// after\nSELECT allowlist::inet[] AS allowlist FROM firewall;","handlingStrategy":"validation","validationCode":"// Confirm the column is a true inet[]/cidr[] array:\nlet t = db.query_one(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a WHERE a.attrelid = 'firewall'::regclass AND a.attname = 'allowlist'\",\n)).await?;\n// expect \"inet[]\"","typeGuard":null,"tryCatchPattern":"// Fall back to text[] decoding plus manual parse when the schema is text-based:\nlet rows = db.query_all(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT allowlist::text[] FROM firewall\",\n)).await?;\nlet ips: Vec<ipnetwork::IpNetwork> = rows[0].try_get::<Vec<String>, _>(0)?\n    .into_iter()\n    .map(|s| s.parse())\n    .collect::<Result<_, _>>()?;","preventionTips":["Store IP lists in inet[]/cidr[] columns, not text[].","Enable with-ipnetwork and postgres-array together on sea-orm.","Cast array_agg results explicitly (array_agg(ip)::inet[]) since array_agg can change types.","Check `pg_typeof(col)` after schema migrations."],"tags":["postgres","network","type-decoding","panic","array","sea-orm"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}