dbt-labs/dbt-core · warning
Valid UTF-8 path
Error message
Valid UTF-8 path
What it means
Test panic from `tmp_file.path().to_str().expect("Valid UTF-8 path")` in `test_keypair_path_with_method_param`. It fires only if the OS-provided temporary file path is not valid UTF-8, which the test then stores into the config as a String. Practically a platform/environment edge case rather than an auth-logic failure.
Source
Thrown at crates/dbt-auth/src/snowflake/mod.rs:1141
snowflake::JWT_PRIVATE_KEY_PKCS8_VALUE,
expected_pem.as_str(),
),
(snowflake::AUTH_TYPE, "auth_jwt"),
(snowflake::APPLICATION_NAME, APP_NAME),
(snowflake::LOG_TRACING, "fatal"),
(snowflake::REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT),
];
run_config_test(config, &expected);
}
#[test]
fn test_keypair_path_with_method_param() {
use std::io::Write;
use tempfile::NamedTempFile;
let mut tmp_file = NamedTempFile::new().expect("Failed to create temp file");
writeln!(tmp_file, "fake-private-key-data").unwrap();
let temp_path = tmp_file.path().to_str().expect("Valid UTF-8 path");
let mut config = base_config_without_password();
config.insert("method".into(), "keypair".into());
config.insert("private_key_path".into(), temp_path.into());
let expected = [
("user", "U"),
("password", ADBC_STUB_PASSWORD),
(snowflake::ACCOUNT, "A"),
(snowflake::ROLE, "role"),
(snowflake::WAREHOUSE, "warehouse"),
(snowflake::JWT_PRIVATE_KEY, temp_path),
(snowflake::AUTH_TYPE, "auth_jwt"),
(snowflake::APPLICATION_NAME, APP_NAME),
(snowflake::LOG_TRACING, "fatal"),
(snowflake::REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT),
];
run_config_test(config, &expected);
}View on GitHub (pinned to 0267ce9170)
Solutions
- Set TMPDIR to a plain ASCII path (e.g. /tmp) before running the tests
- Verify locale/encoding settings (LANG/LC_ALL as UTF-8)
- If paths must be arbitrary, refactor the test/config to use PathBuf instead of str
Example fix
// before TMPDIR="/tmp/ünïcødé" cargo test -p dbt-auth // after export TMPDIR=/tmp && cargo test -p dbt-auth test_keypair_path_with_method_param
Defensive patterns
Strategy: type-guard
Validate before calling
let p = tmp_file.path();
assert!(p.to_str().is_some(), "temp path not UTF-8: {:?}", p); Type guard
fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() } Prevention
- Set TMPDIR to an ASCII path in CI and dev environments
- Use UTF-8 locales (LANG=C.UTF-8)
- Prefer PathBuf over String for paths in library APIs
When it happens
Trigger: Running the test on a system whose temp directory path (from TMPDIR or the OS default) contains non-UTF-8 bytes — e.g. a TMPDIR with non-ASCII/invalid-encoding bytes on Linux.
Common situations: Environments with unusual TMPDIR values, locales with non-UTF-8 encodings, or container mounts with odd path names.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/f71f288f3478653f.
Report an issue: GitHub.