We don't always get the flags property on the config object that gets used to create a BaseAdapter instance. This happens whenever project.yml is not loaded. In particular, this happens during dbt debug, which is meant to be a quick check of whether we can connect to a database; this command only requires profile.yml.
The decision was initially made to not load any behavior flags in the scenarios where project.yml was not loaded. The rationale there was that we did not want to return one value for a behavior flag when project.yml is not loaded (hence the default) and another value for the behavior flag when project.yml is loaded (the default, potentially overridden by the user). However, in the former scenario, referencing the behavior flag at all results in a CompilationError since the flag does not exist on BaseAdapter.behavior. This is not desirable behavior either.
Solution
While the behavior flags are loaded onto BaseAdapter.behavior dynamically, the object should always have the same flags available. Since the user's overrides are not available when project.yml is not loaded, we should act as if project.yml was loaded, but without a flags node. In other words, we should simply assume the default values when we don't get a flags attribute.
[x] I have run this code in development, and it appears to resolve the stated issue
[x] This PR includes tests, or tests are not required/relevant for this PR
[x] This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.
Problem
We don't always get the
flags
property on theconfig
object that gets used to create aBaseAdapter
instance. This happens wheneverproject.yml
is not loaded. In particular, this happens duringdbt debug
, which is meant to be a quick check of whether we can connect to a database; this command only requiresprofile.yml
.The decision was initially made to not load any behavior flags in the scenarios where
project.yml
was not loaded. The rationale there was that we did not want to return one value for a behavior flag whenproject.yml
is not loaded (hence the default) and another value for the behavior flag whenproject.yml
is loaded (the default, potentially overridden by the user). However, in the former scenario, referencing the behavior flag at all results in aCompilationError
since the flag does not exist onBaseAdapter.behavior
. This is not desirable behavior either.Solution
While the behavior flags are loaded onto
BaseAdapter.behavior
dynamically, the object should always have the same flags available. Since the user's overrides are not available whenproject.yml
is not loaded, we should act as ifproject.yml
was loaded, but without aflags
node. In other words, we should simply assume the default values when we don't get aflags
attribute.Checklist