dbt-labs/dbt-core · error · minijinja::Error::InvalidOperation
dataset in a GrantAccessToTarget cannot be empty
Error message
dataset in a GrantAccessToTarget cannot be empty
What it means
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.
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.
Example fix
// before
{% do adapter.grant_access_to(entity, 'view', 'viewer', {'project': 'my-project', 'schema': 'shared'}) %}
// after
{% do adapter.grant_access_to(entity, 'view', 'viewer', {'project': 'my-project', 'dataset': 'shared'}) %} Defensive patterns
Strategy: validation
Validate before calling
{% if grant_target.get('dataset') is defined and grant_target.get('dataset') is not none %}
{% do adapter.grant_access_to(entity, 'view', 'viewer', grant_target) %}
{% else %}
{{ exceptions.raise_compiler_error("grant target requires a non-empty dataset") }}
{% endif %} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- project in a GrantAccessToTarget cannot be empty
- adapter.add_time_ingestion_partition_column failed on…
- adapter.parse_partition_by failed on
- An unexpected error occurred during package installation
- 'api_endpoint' is missing a trailing '/', which dbt appends…
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/d8beda4c60c95991.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-adapter/src/adapter/mod.rs:2302
let grant_target = minijinja_value_to_typed_struct::<GrantAccessToTarget>(
grant_target_dict.clone(),
)
.map_err(|e| {
minijinja::Error::new(
minijinja::ErrorKind::SerdeDeserializeError,
e.to_string(),
)
})?;
iter.finish()?;
let database = grant_target.project.as_deref().ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"project in a GrantAccessToTarget cannot be empty",
)
})?;
let schema = grant_target.dataset.as_deref().ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"dataset in a GrantAccessToTarget cannot be empty",
)
})?;
let role = if role_val.is_none() || role_val.is_undefined() {
None
} else {
Some(role_val.as_str().ok_or_else(|| {
minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"role must be a string",
)
})?)
};
let entity = downcast_value_to_dyn_base_relation(entity_val)?;
View on GitHub (pinned to 0267ce9170)