{"record":{"id":"d8beda4c60c95991","repo":"dbt-labs/dbt-core","slug":"dataset-in-a-grantaccesstotarget-cannot-be-empty","errorCode":null,"errorMessage":"dataset in a GrantAccessToTarget cannot be empty","messagePattern":"dataset in a GrantAccessToTarget cannot be empty","errorType":"exception","errorClass":"minijinja::Error::InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/adapter/mod.rs","lineNumber":2302,"sourceCode":"                let grant_target = minijinja_value_to_typed_struct::<GrantAccessToTarget>(\n                    grant_target_dict.clone(),\n                )\n                .map_err(|e| {\n                    minijinja::Error::new(\n                        minijinja::ErrorKind::SerdeDeserializeError,\n                        e.to_string(),\n                    )\n                })?;\n                iter.finish()?;\n\n                let database = grant_target.project.as_deref().ok_or_else(|| {\n                    minijinja::Error::new(\n                        minijinja::ErrorKind::InvalidOperation,\n                        \"project in a GrantAccessToTarget cannot be empty\",\n                    )\n                })?;\n                let schema = grant_target.dataset.as_deref().ok_or_else(|| {\n                    minijinja::Error::new(\n                        minijinja::ErrorKind::InvalidOperation,\n                        \"dataset in a GrantAccessToTarget cannot be empty\",\n                    )\n                })?;\n\n                let role = if role_val.is_none() || role_val.is_undefined() {\n                    None\n                } else {\n                    Some(role_val.as_str().ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::InvalidOperation,\n                            \"role must be a string\",\n                        )\n                    })?)\n                };\n\n                let entity = downcast_value_to_dyn_base_relation(entity_val)?;\n","sourceCodeStart":2284,"sourceCodeEnd":2320,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/adapter/mod.rs#L2284-L2320","documentation":"grant_access_to() also requires a non-empty `dataset` in the GrantAccessToTarget: the dataset identifies the target BigQuery dataset being granted access. If grant_target.dataset is missing or None after deserialization, this InvalidOperation error is raised stating the dataset cannot be empty.","triggerScenarios":"adapter.grant_access_to(entity, entity_type, role, {'project': 'my-project'}) — project present but dataset key absent or null; passing {'project': ..., 'schema': ...} using the wrong key name so dataset deserializes to None.","commonSituations":"BigQuery grant macros using `schema` terminology instead of BigQuery's `dataset`; grant configs copied from other warehouses that use schema/database naming; typos in the grants configuration.","solutions":["Include `dataset` (not `schema`) with a string value in the grant target dict.","Fix the key name if you used `schema` — GrantAccessToTarget expects `project` and `dataset`.","Check the error and preceding grant configuration in macros/grants to ensure both fields are populated.","Validate the grant target dict shape before calling the adapter."],"exampleFix":"// before\n{% do adapter.grant_access_to(entity, 'view', 'viewer', {'project': 'my-project', 'schema': 'shared'}) %}\n\n// after\n{% do adapter.grant_access_to(entity, 'view', 'viewer', {'project': 'my-project', 'dataset': 'shared'}) %}","handlingStrategy":"validation","validationCode":"{% if grant_target.get('dataset') is defined and grant_target.get('dataset') is not none %}\n  {% do adapter.grant_access_to(entity, 'view', 'viewer', grant_target) %}\n{% else %}\n  {{ exceptions.raise_compiler_error(\"grant target requires a non-empty dataset\") }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the `dataset` key (BigQuery terminology), not `schema`","Validate both project and dataset are present before granting","Keep grant macros consistent with GrantAccessToTarget's field names"],"tags":["bigquery","grants","missing-field"],"backgroundTag":"empty-required-field","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"}