-
Notifications
You must be signed in to change notification settings - Fork 54
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
[SNOW-1462584] Implement setup script validation #1161
Conversation
48ee3a5
to
6fd6ce6
Compare
f"call system$validate_native_app_setup('{stage_name}')" | ||
) | ||
except ProgrammingError as err: | ||
if "does not exist or not authorized" in err.msg: |
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.
Since the App Pkg does not exist error is a specific error, we should possibly tighten the constraint on this condition with an and
on the error number.
Once case I'm thinking of but is not necessarily true today: "does not exist or not authorized" could be thrown if some setup script is missing or permissions change that setup script cannot be accessed.
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.
if a permission issue hides the visibility of the app package, wouldn't that be functionally equivalent to it not existing, from the PoV of the user? I can update the exception's error message to add "or is not authorized" (i'll add the errno check too)
e998cb3
to
811329b
Compare
snow app validate
commandaebd7a0
to
365f311
Compare
messages = [ | ||
_validation_item_to_str(error) | ||
for error in validation_result.get("errors", []) | ||
] | ||
raise SetupScriptFailedValidation(messages) |
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.
any reason we shouldn't print the errors as we do with the warnings, and fail with a "validation failed" generic message?
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.
there was no specific reason, but looking back I like it like that since it separates errors and warnings, and it makes the errors really obvious by printing them inside the ASCII box art (see the screenshot in the PR description). I'm not opposed to changing it if it's a blocker
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.
I think we'll want to control how we format these messages, and this way of outputting them will prevent us from doing that. I'll do a pass on the overall output this week or next week, it's long overdue. We should sync on that, but I'm fine if validate becomes slightly inconsistent (but better) while the other commands catch up.
IMHO we keep the box small and generic here (something like "Validation failed, re-run with --no-validate to skip this check"). We output errors the same way as we do warnings, but maybe we make them visually stand out in the output (maybe we use shell colors to highlight errors?)
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.
|
||
def validate(self, use_scratch_stage: bool = False): | ||
"""Validates Native App setup script SQL.""" | ||
cc.step(f"Validating Snowflake Native App setup script.") |
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.
Is validation a phase? It looks like it will output nested messages, hence the question.
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.
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.
The diff output is bad, I have a fix locally that I will submit in the next few days. So it's not a really good comparison.
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.
changed it to a phase
d2d8401
to
323ff2f
Compare
messages = [ | ||
_validation_item_to_str(error) | ||
for error in validation_result.get("errors", []) | ||
] | ||
raise SetupScriptFailedValidation(messages) |
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.
I think we'll want to control how we format these messages, and this way of outputting them will prevent us from doing that. I'll do a pass on the overall output this week or next week, it's long overdue. We should sync on that, but I'm fine if validate becomes slightly inconsistent (but better) while the other commands catch up.
IMHO we keep the box small and generic here (something like "Validation failed, re-run with --no-validate to skip this check"). We output errors the same way as we do warnings, but maybe we make them visually stand out in the output (maybe we use shell colors to highlight errors?)
1485c46
to
f1aa991
Compare
… `snow app validate` use a scratch stage.
…_with_stage call in version tests
79a3e55
to
b495ac4
Compare
Pre-review checklist
Changes description
Calls
system$validate_native_app_setup()
to validate the setup script in the stage onsnow app deploy
,snow app run
, and the newsnow app validate
. The validation is done server-side, all we need to do is raise an error and show messages if the validation failed.For
snow app validate
, we use a scratch stage to avoid clobbering the app's dev stage in between deploys. This stage is deleted after every validation run and onsnow app teardown
to avoid leaving behind any garbage.Scenarios
App has warning but no errors (exit code 0):
App has validation errors (exit code 1):
Deploy-time validation error (exit code 1, notice it's using the app's stage and not the scratch stage):
Skip validation at deploy time (exit code 0):
JSON output (exit code 0 regardless of status):