parse_mod_info: Filter empty strings to marshmallow doesn't get angry#33
Open
duk3luk3 wants to merge 2 commits intoFAForever:developfrom
Open
parse_mod_info: Filter empty strings to marshmallow doesn't get angry#33duk3luk3 wants to merge 2 commits intoFAForever:developfrom
duk3luk3 wants to merge 2 commits intoFAForever:developfrom
Conversation
Member
|
Don't you just want to update the schema with |
Member
Author
|
Ah, I didn't know that was possible! I didn't find that in the marshmallow docs when I was looking. |
Member
Author
|
This doesn't actually work, and apparently the workaround is to remove all "empty" values before passing the data to marshmallow - marshmallow-code/marshmallow#167 (comment) For a schema description tool this is kind of shite. |
When we execute lua scripts to extract the global variables they set, we are not interested in the things that already hang around in the globals table when the Lua VM is initialized. Since these things also contain binary that we don't want to run through string decoding (resulting in `UnicodeDecodeError`), we're better off getting rid of them.
marshmallow does not like empty strings in `UrlField`s and therefore failed validation if a `mod_info.lua` contained `url = ""`. This commit removes all `None` and `""` values from the data before passing it to the marshmallow schema. Fixes FAForever#31
2596548 to
6687cab
Compare
Member
Author
|
@Sheeo can you reproduce that without my commit to ignore the "internal" lua globals using |
Member
Author
|
Here is what it takes for me to trigger the problem: from faf.tools.lua import parse
parse.from_lua('')results in this: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
marshmallow does not like empty strings in
UrlFields and therefore failed validation if amod_info.luacontainedurl = "".This commit removes all
Noneand""values from the data before passing it to the marshmallow schema.Fixes #31
Also contains a lua fix:
Ignore "internal" globals when parsing lua: When we execute lua scripts to extract the global variables they set, we are not interested in the things that already hang around in the globals table when the Lua VM is initialized.
Since these things also contain binary that we don't want to run through string decoding (resulting in
UnicodeDecodeError), we're better off getting rid of them.