{"record":{"id":"8313bc9b54ef63be","repo":"dbt-labs/dbt-core","slug":"configure-8313bc","errorCode":null,"errorMessage":"configure","messagePattern":"configure","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-auth/src/sqlserver/mod.rs","lineNumber":287,"sourceCode":"        AdapterConfig::new(Mapping::from_iter(\n            pairs.into_iter().map(|(k, v)| (k.into(), v.into())),\n        ))\n    }\n\n    #[test]\n    fn test_service_principal_with_tenant_id() {\n        let config = make_config([\n            (\"authentication\", \"serviceprincipal\"),\n            (\"host\", \"myserver.database.windows.net\"),\n            (\"database\", \"mydb\"),\n            (\"tenant_id\", \"my-tenant\"),\n            (\"client_id\", \"my-client\"),\n            (\"client_secret\", \"my-secret\"),\n        ]);\n\n        let outcome = SQLServerAuth::new(Box::new(crate::NoopAuthWarningPrinter))\n            .configure(&config)\n            .expect(\"configure\");\n        let uri = uri_value(&outcome);\n\n        assert_contains!(&uri, \"sqlserver://myserver.database.windows.net:1433\");\n        assert_contains!(&uri, \"database=mydb\");\n        assert_contains!(&uri, \"fedauth=ActiveDirectoryServicePrincipal\");\n        assert_contains!(&uri, \"user+id=my-client%40my-tenant\");\n        assert_contains!(&uri, \"password=my-secret\");\n    }\n\n    #[test]\n    fn test_service_principal_without_tenant_id() {\n        let config = make_config([\n            (\"authentication\", \"ActiveDirectoryServicePrincipal\"),\n            (\"host\", \"myserver.database.windows.net\"),\n            (\"database\", \"mydb\"),\n            (\"client_id\", \"my-client\"),\n            (\"client_secret\", \"my-secret\"),\n        ]);","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-auth/src/sqlserver/mod.rs#L269-L305","documentation":"SQLServerAuth::configure returns Result<database::Builder, AuthError>; here it runs parse_auth, apply_connection_args, and the service-principal apply step. `.expect(\"configure\")` panics when any stage yields AuthError. For `authentication: serviceprincipal` the library builds a `sqlserver://` URI with fedauth=ActiveDirectoryServicePrincipal and user+id=<client_id>%40<tenant_id>; the error means the service-principal profile could not be parsed or applied (missing/invalid tenant_id, client_id, client_secret, host, or database).","triggerScenarios":"Calling SQLServerAuth::configure with a config whose authentication is `serviceprincipal` (as in crates/dbt-auth/src/sqlserver/mod.rs:287) but where parse_auth cannot build the ServicePrincipal IR — e.g. missing `tenant_id`, `client_id`, or `client_secret`, non-string values, or an unrecognized authentication value.","commonSituations":"Test updates to the service-principal URI format (e.g. percent-encoded tenant suffix) that no longer match parse_auth; profiles omitting tenant_id; refactors of the SQLServer AuthIR that narrow accepted key spellings (`authentication` vs `auth_type`).","solutions":["Read the AuthError message after `configure: ` in the panic to find which key failed.","Ensure the Mapping has string values for authentication=serviceprincipal, tenant_id, client_id, client_secret, host, database.","If URI construction fails, check the apply step that appends user+id=<client>%40<tenant> and fedauth=ActiveDirectoryServicePrincipal.","Keep authentication values lowercase `serviceprincipal` (or the accepted alias) exactly as parse_auth expects.","Run `cargo test -p dbt-auth sqlserver::tests::test_service_principal_with_tenant_id` to iterate narrowly."],"exampleFix":"// before\nlet config = make_config([\n    (\"authentication\", \"serviceprincipal\"),\n    (\"host\", \"myserver.database.windows.net\"),\n    // tenant_id missing -> configure errs\n    (\"client_id\", \"my-client\"),\n    (\"client_secret\", \"my-secret\"),\n]);\n// after\nlet config = make_config([\n    (\"authentication\", \"serviceprincipal\"),\n    (\"host\", \"myserver.database.windows.net\"),\n    (\"database\", \"mydb\"),\n    (\"tenant_id\", \"my-tenant\"),\n    (\"client_id\", \"my-client\"),\n    (\"client_secret\", \"my-secret\"),\n]);","handlingStrategy":"validation","validationCode":"fn ensure_service_principal(config: &AdapterConfig) -> Result<(), String> {\n    for key in [\"authentication\", \"host\", \"client_id\", \"client_secret\"] {\n        if config.get_str(key).is_none() {\n            return Err(format!(\"service principal profile missing `{key}`\"));\n        }\n    }\n    if config.get_str(\"database\").is_none() {\n        return Err(\"service principal profile missing `database`\".into());\n    }\n    // tenant_id optional; when present it is appended as client_id%40tenant_id\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Supply tenant_id, client_id, client_secret as strings in the profile","Match the accepted authentication spellings (serviceprincipal / ActiveDirectoryServicePrincipal)","Validate host:database before configure to get a well-formed sqlserver:// URI","Handle AuthError via Result instead of expect in production code","Keep URI-encoding expectations (%40 separator) in sync with the apply step"],"tags":["rust","auth","sqlserver","service-principal","config-panic"],"backgroundTag":"missing-required-config-field","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}