Add a better error for undefined macros#3343
Conversation
c0db921 to
08ab5de
Compare
|
The issue talks about the possibility of comparing |
08ab5de to
eb433bd
Compare
eb433bd to
18f7477
Compare
|
@jaypeedevlin I just left a comment over in #2999! I think there's a way we can do both :) |
jtcohen6
left a comment
There was a problem hiding this comment.
Okay, I think I figured out why the tests are failing! There's one integration test in particular, however, that expects to fail when its package is missing, and raise a helpful error message, before it actually runs deps:
I think we could either:
- Split apart the test into a Failing and Passing version. In the former, the
packages_configshould be empty (thereby passing the check we're adding in this PR), and we can still confirm that sourceoverridesraise a helpful error message if their associated package is missing. Then, the Passing version has a reasonablepackages_configand runsdepsright away. - Remove that piece of the test. With this amazing new error message, no one should ever have this problem ever again!
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
|
Thanks for the pointers, we're looking in much better shape now. Here's what I have as outstanding:
|
jtcohen6
left a comment
There was a problem hiding this comment.
Nice, we're really close!
I left comments for mypy (let's cheat) and 029_docs_generate (seems like we were never using the package at all).
As far as the 100_rpc_test, here is the problematic bit:
Namely, line 1146 returns:
E AssertionError: 'error' != 'ready'
E - error
E + ready
Why? Now that we raise a compilation error as soon as we detect a mismatch between packages.yml and dbt_modules, the RPC server will really aggressively raise that error on startup/sighup. Previously, we tested starting up an RPC server and checking that it's "ready" (even though it's missing a dependency), now it returns "error" status:
{'result': {'logs': [], 'state': 'error', 'error': {'message': 'Compilation Error\n dbt found 1 package(s) specified in packages.yml, but only 0 package(s) installed in dbt_modules. Run "dbt deps" to install package dependencies.'}, 'timestamp': '2021-05-17T22:00:29.817312Z', 'pid': 62478}, 'id': 1, 'jsonrpc': '2.0'}
This is a positive change IMO! So we just need to rework the test accordingly:
def _check_start_predeps(self):
self.assertFalse(os.path.exists('./dbt_modules'))
status = self.assertIsResult(self.query('status').json())
# will return an error because defined dependency is missing
self.assertEqual(status['state'], 'error')
return statusCo-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
|
Ok, nothing makes you feel like you're on the right track quite like some mysterious RPC test errors! I figured out what's going on here for This is, I realize, an opinionated change to how the RPC server works. Today, if there are packages defined but not installed, Here's what that looks like in the test case: We need:
|
|
That the previous commit passed is interesting — I still had a single failing test locally. I'm going to fix the merge conflicts and see if it passes on a second go! |
jtcohen6
left a comment
There was a problem hiding this comment.
@jaypeedevlin This sure looks good to me! Thanks so much for the contribution :)
* Add a better error for undefined macros * Add check/error when installed packages < specified packages * fix integration tests * Fix issue with null packages * Don't call _get_project_directories() twice Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> * Fix some integration and unit tests * Make mypy happy Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> * Fix docs and rpc integration tests * Fix (almost) all the rpc tests Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> automatic commit by git-black, original commits: 17555fa
resolves #2999
Description
Adds a new
UndefinedMacroExceptionand raises this when an undefined macro is caught.Checklist
CHANGELOG.mdand added information about my change to the "dbt next" section.