{"record":{"id":"e2601aafa6a4e6a4","repo":"dbt-labs/dbt-core","slug":"table-rename-column-names-array-must-contain-only","errorCode":null,"errorMessage":"Table.rename: column_names array must contain only strings, found: {}","messagePattern":"Table\\.rename: column_names array must contain only strings, found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":693,"sourceCode":"                    // Try to treat it as a generic iterable\n                    let iter = match v.try_iter() {\n                        Ok(iter) => iter,\n                        Err(_) => {\n                            return Err(Error::new(\n                                ErrorKind::InvalidArgument,\n                                \"Table.rename: column_names must be a map or an array\",\n                            ));\n                        }\n                    };\n                    let mut renamed = old;\n                    for (i, value) in iter.enumerate() {\n                        if i >= renamed.len() {\n                            break;\n                        }\n                        if let Some(s) = value.as_str() {\n                            renamed[i] = s.to_string();\n                        } else {\n                            return Err(Error::new(\n                                ErrorKind::InvalidArgument,\n                                format!(\n                                    \"Table.rename: column_names array must contain only strings, found: {}\",\n                                    value\n                                ),\n                            ));\n                        }\n                    }\n                    Ok(renamed)\n                }\n            })\n            .transpose()?;\n\n        // Renaming of rows\n        let old_row_name = |i| -> Option<&str> {\n            self.repr.row_names.as_ref().and_then(|names| {\n                if names.as_ref().is_valid(i) {\n                    Some(names.value(i))","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L675-L711","documentation":"When column_names is given as an array to Table.rename, every element must be a string (the new column name). The library found a non-string element while assigning new names positionally and includes the offending value in the message.","triggerScenarios":"Calling table.rename with an array column_names containing numbers, nulls, booleans, or nested values, e.g. [\"a\", 2, null].","commonSituations":"Programmatically building the name list from mixed sources (parsed CSV headers mixed with placeholders); JSON config where names were numbers; forgetting to stringify values read from a config file.","solutions":["Ensure every element of the column_names array is a string before calling rename.","Convert numeric or other elements with a string conversion step, e.g. value.to_string().","Use the map form {\"old\": \"new\"} instead if you want selective renaming."],"exampleFix":"// before\nrename(Some(vec![\"a\", 2]), None, false, false)\n// after\nrename(Some(vec![\"a\", \"b\"]), None, false, false)","handlingStrategy":"type-guard","validationCode":"let all_strings = column_names.iter().all(|v| v.as_str().is_some());\nif !all_strings { panic!(\"column_names must contain only strings\"); }","typeGuard":"fn all_strings(v: &[Value]) -> bool {\n    v.iter().all(|x| x.as_str().is_some())\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"array must contain only strings\") => {\n        let coerced: Vec<String> = raw_names.iter().map(|v| v.to_string()).collect();\n        table.rename(Some(coerced), None, false, false)?\n    }\n    other => other?,\n}","preventionTips":["Stringify all elements before building the names array.","Avoid mixing typed values and strings in name lists.","Add a unit test asserting every element is a string."],"tags":["argument-validation","rename","type-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}