-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
Allow output_schema
to validate non-object action output (int, bool, etc)
#5319
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b0fc392
to
71e1a8c
Compare
m4dcoder
requested changes
Aug 5, 2021
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 got some questions.
This should handle any nested objects/arrays etc. We might need to adjust the output_schema to support non-objects but that can be done separately, I hope.
This comment was marked as outdated.
This comment was marked as outdated.
Here is the offending yaml file. Yes it was malformed. |
m4dcoder
previously requested changes
Aug 10, 2021
7 tasks
rush-skills
approved these changes
Jul 10, 2022
amanda11
reviewed
Jul 11, 2022
amanda11
approved these changes
Jul 12, 2022
I addressed the feedback and asked for permission to dismiss the review on slack. @m4dcoder responded with 🆗
Documentation added in StackStorm/st2docs#1137 |
cognifloyd
added a commit
to StackStorm/st2docs
that referenced
this pull request
Jul 20, 2022
document output_schema and output_schema masking per StackStorm/st2#5319
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug fix
enhancement
output schema
size/XXL
PR that changes 1000+ lines. You should absolutely split your PR into several.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR turns
output_schema
into a full jsonschema which provides several benefits.We ignore schemas that are not well-formed to avoid throwing errors. But, we now log a warning when a schema is invalid as an invalid schema prevents validation and secret masking from working.
If anyone is using
output_schema
, they will need to update metadata to keep using ouptut validation and secret masking.For example, this schema:
should be updated like this:
This builds on #5309 to refactor the output_schema validation and add missing tests.
Ultimately, this is a follow-up for #5250 which added secret-masking to the output_schema validation, but missed some of the possible data types for output_values.
Before this PR,
ouptut_schema
could only do output_validation and secret masking for properties of objects.The runner schema required that output_schema be an object and
patternProperties
here allowed each property to be a schema:st2/st2common/st2common/models/api/action.py
Lines 119 to 125 in b8402b4
And the same applies to action schema:
st2/st2common/st2common/models/api/action.py
Lines 231 to 237 in b8402b4
This is where the schema for each output_schema property schema is loaded:
st2/st2common/st2common/util/schema/__init__.py
Lines 89 to 95 in b8402b4
st2/st2common/st2common/util/schema/__init__.py
Lines 57 to 59 in b8402b4
And
action_output_schema.json
is the full json schema spec with our extensions (secret masking, etc)st2/st2common/st2common/util/schema/action_output_schema.json
Lines 2 to 4 in b8402b4
st2/st2common/st2common/util/schema/action_output_schema.json
Lines 92 to 99 in b8402b4
Since
output_schema
usedpatternProperties
, it could only validate objects - the only type that has properties. If your action or runner needed to output any other types (list, int, bool, ...), then output_validation and secret masking was unavailable. And, if your action provided an object whose keys needed to be masked (vs the property values), then that was also not possible.