{"record":{"id":"5b9cf84c146b8365","repo":"dbt-labs/dbt-core","slug":"quote-key-must-be-one-of-database-schema-identi","errorCode":null,"errorMessage":"quote_key must be one of: database, schema, identifier","messagePattern":"quote_key must be one of: database, schema, identifier","errorType":"exception","errorClass":"minijinja::Error::InvalidArgument","httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/adapter/mod.rs","lineNumber":635,"sourceCode":"    ///     identifier: str,\n    ///     quote_key: str\n    /// ) -> str\n    /// ```\n    #[tracing::instrument(skip_all, level = \"trace\")]\n    pub fn quote_as_configured(\n        &self,\n        state: &State,\n        args: &[Value],\n    ) -> Result<Value, minijinja::Error> {\n        match &self.inner {\n            Typed { adapter, .. } => {\n                let iter = ArgsIter::new(\"quote_as_configured\", &[\"identifier\", \"quote_key\"], args);\n                let identifier = iter.next_arg::<&str>()?;\n                let quote_key = iter.next_arg::<&str>()?;\n                iter.finish()?;\n\n                let quote_key = quote_key.parse::<ComponentName>().map_err(|_| {\n                    minijinja::Error::new(\n                        minijinja::ErrorKind::InvalidArgument,\n                        \"quote_key must be one of: database, schema, identifier\",\n                    )\n                })?;\n\n                let result = adapter.quote_as_configured(state, identifier, &quote_key)?;\n\n                Ok(Value::from(result))\n            }\n            Parse(_) => Ok(empty_string_value()),\n        }\n    }\n\n    /// Quote seed column.\n    ///\n    /// https://github.com/dbt-labs/dbt-adapters/blob/5fba80c621c3f0f732dba71aa6cf9055792b6495/dbt-adapters/src/dbt/adapters/base/impl.py#L1091\n    ///\n    /// ```python","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/adapter/mod.rs#L617-L653","documentation":"`quote_as_configured` takes a `quote_key` string that must parse into a `ComponentName` (database, schema, or identifier). When parsing fails the adapter raises this InvalidArgument error listing the valid values. It prevents arbitrary quoting keys from reaching the quoting policy logic.","triggerScenarios":"Calling adapter.quote_as_configured(identifier, quote_key) with quote_key not exactly one of 'database', 'schema', 'identifier' — e.g. a typo like 'schema_name', mixed case, or a dynamically built key from config.","commonSituations":"Macros or custom materializations compute the quoting component from Jinja config values; a missing/renamed config yields an unexpected key string that fails ComponentName::from_str.","solutions":["Use only the literal strings 'database', 'schema', or 'identifier' as quote_key","If the key comes from config, validate/normalize it (lowercase, trim) before calling","Add a Jinja-side check that raises a clearer message when the configured quoting component is unrecognized"],"exampleFix":"// before\nadapter.quote_as_configured(name, \"Schema\")\n// after\nadapter.quote_as_configured(name, \"schema\")","handlingStrategy":"validation","validationCode":"// guard before calling\nconst VALID: [&str; 3] = [\"database\", \"schema\", \"identifier\"];\nif !VALID.contains(&quote_key) {\n    return Err(format!(\"quote_key '{quote_key}' invalid; must be database|schema|identifier\"));\n}","typeGuard":"fn is_valid_quote_key(k: &str) -> bool {\n    matches!(k, \"database\" | \"schema\" | \"identifier\")\n}","tryCatchPattern":"let quote_key = quote_key.parse::<ComponentName>().map_err(|_| {\n    minijinja::Error::new(minijinja::ErrorKind::InvalidArgument,\n        \"quote_key must be one of: database, schema, identifier\")\n})?;","preventionTips":["Hardcode the literal quote keys instead of deriving them from config strings","Normalize config-provided quoting keys (lowercase/trim) before use","Enumerate the allowed values in macro docs and error messages"],"tags":["quoting","argument-validation","minijinja"],"backgroundTag":"invalid-enum-value","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}