-
Notifications
You must be signed in to change notification settings - Fork 279
Handle Exception during dab validate when SqlMetadataProvider has not correctly initialized #2202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle Exception during dab validate when SqlMetadataProvider has not correctly initialized #2202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few nits, but looks good!
/azp run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we validate backing columns if we know connection string is incorrect?
…b.com:Azure/data-api-builder into dev/aaronburtle/DabValidateUnhandledException
…vided DB meta, and generated Db meta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some additional changes needed.
/azp run |
Might not need this
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions. LGTM otherwise! Thanks for fixing the dab validate command!
/azp run |
feedback addressed, removing stale review.
Why make this change?
Closes #2184
Closes #2180
What is this change?
When we don't properly initialize the
SqlMetadataProvider
, certain functions will not behave as intended. This change adds some defensive programming around this fact so that we have more readable exceptions in these cases, as well as restructuring the validation to avoid the potential of such a circumstance.We refactor the
ValidateEntitiesMetadata
function into 2 functions, one calledValidateRelationshipConfigCorrectness
that validates the relationships in the config without needing to cross reference database metadata, and leaving the remaining validations that do require such metadata within the original function. This validation is then handled by a mix of the initialization of the metadata provider (this init process does some validation), and the call toValidateRelationships
which happens from withinValidateEntitiesMetadata
only when the initialization of the metadata provider resulted in no connection errors.Therefore, the normal code path when doing
dab validate
will beValidateRelationshipConfigCorrectness
ValidateEntitiesMetadata
2a. If there were no connection errors Call
ValidateRelationships
How was this tested?
Manually, against our test suite, and we add a regression test that looks for the correct error messaging when the config that caused the error from the finding of the bug is used.
Sample Request(s)
This can be reprod by using the command `dab validate -c