{"record":{"id":"525fe6447a93992e","repo":"dbt-labs/dbt-core","slug":"failed-to-create-temp-file","errorCode":null,"errorMessage":"Failed to create temp file","messagePattern":"Failed to create temp file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/dbt-auth/src/snowflake/mod.rs","lineNumber":1139,"sourceCode":"            (snowflake::WAREHOUSE, \"warehouse\"),\n            (\n                snowflake::JWT_PRIVATE_KEY_PKCS8_VALUE,\n                expected_pem.as_str(),\n            ),\n            (snowflake::AUTH_TYPE, \"auth_jwt\"),\n            (snowflake::APPLICATION_NAME, APP_NAME),\n            (snowflake::LOG_TRACING, \"fatal\"),\n            (snowflake::REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT),\n        ];\n        run_config_test(config, &expected);\n    }\n\n    #[test]\n    fn test_keypair_path_with_method_param() {\n        use std::io::Write;\n        use tempfile::NamedTempFile;\n\n        let mut tmp_file = NamedTempFile::new().expect(\"Failed to create temp file\");\n        writeln!(tmp_file, \"fake-private-key-data\").unwrap();\n        let temp_path = tmp_file.path().to_str().expect(\"Valid UTF-8 path\");\n\n        let mut config = base_config_without_password();\n        config.insert(\"method\".into(), \"keypair\".into());\n        config.insert(\"private_key_path\".into(), temp_path.into());\n        let expected = [\n            (\"user\", \"U\"),\n            (\"password\", ADBC_STUB_PASSWORD),\n            (snowflake::ACCOUNT, \"A\"),\n            (snowflake::ROLE, \"role\"),\n            (snowflake::WAREHOUSE, \"warehouse\"),\n            (snowflake::JWT_PRIVATE_KEY, temp_path),\n            (snowflake::AUTH_TYPE, \"auth_jwt\"),\n            (snowflake::APPLICATION_NAME, APP_NAME),\n            (snowflake::LOG_TRACING, \"fatal\"),\n            (snowflake::REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT),\n        ];","sourceCodeStart":1121,"sourceCodeEnd":1157,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-auth/src/snowflake/mod.rs#L1121-L1157","documentation":"Test panic from `NamedTempFile::new().expect(\"Failed to create temp file\")` in `test_keypair_path_with_method_param`. It fires when the OS refuses to create the temporary key file the test needs (tempdir unavailable, permissions, disk full). The expect message is generic infrastructure, unrelated to keypair auth logic itself.","triggerScenarios":"Running `cargo test -p dbt-auth` in an environment where `std::env::temp_dir()` is unwritable or `TMPDIR` points to a read-only/nonexistent path; sandboxed CI with restricted /tmp; low file-descriptor or disk limits.","commonSituations":"CI containers with no writable /tmp, restricted dev sandboxes, or a bad TMPDIR env var; macOS/Linux permission changes on /tmp.","solutions":["Ensure TMPDIR points to a writable directory (e.g. export TMPDIR=/tmp or a project-local dir)","Fix filesystem permissions on the temp directory for the test user","Check disk space / inode and file-descriptor limits before rerunning the tests"],"exampleFix":"// before\nTMPDIR=/nonexistent cargo test -p dbt-auth\n// after\nexport TMPDIR=$(mktemp -d) && cargo test -p dbt-auth test_keypair_path_with_method_param","handlingStrategy":"validation","validationCode":"let tmp = std::env::temp_dir();\nassert!(tmp.is_dir() && !tmp.read_only(), \"temp dir unwritable: {:?}\", tmp);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep TMPDIR pointing at a writable directory in CI images","Monitor disk space and fd limits on test runners","Use mktemp-based TMPDIR in sandboxes"],"tags":["rust","tests","filesystem","tempfile"],"backgroundTag":"file-write-failed","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"}