Closed caseycesari closed 6 years ago
Is there specific line/column information in the thrown ValueError
that can be relayed to the user? Notifying of "proper formatting" may not be enough detail to let a site admin fully diagnose the issue.
Re: ValueError. I don't think so, but let me double-check. The python json
library complains that the object it is trying to load isn't JSON. Maybe there is a JSON validation library I can try that will pinpoint the error.
The raise
statements (removed in cf5a65d) fed the error including line number (which is approximate, the error is arguably Line 2, col 22). Not abundantly clear what file the issue is in, if you don't have experience reading error stack traces.
For ref, the error in region.json
:
Thanks @fungjj92! I'll try and add that back in the new structure.
Okay. Fixed up the messages. Here's what they look like now:
INFO:root:Attempting to compile static assets...
Failed! Check that your JSON config files are properly formatted. Expecting , delimiter: line 3 column 5 (char 27)
WARNING:root:1
INFO:root:Attempting to compile static assets...
Failed! Check that your JSON config files match their schemas. 1 is not of type u'string'
Failed validating u'type' in schema[u'properties'][u'language']:
{u'required': False, u'type': u'string'}
On instance[u'language']:
1
WARNING:root:1
INFO:root:Attempting to compile static assets...
Failed! Check that the plugin JSON config file located at /Users/ccesari/projects/GeositeFramework/src/GeositeFramework/sample_plugins/identify_point/plugin.json is properly formatted. Expecting , delimiter: line 5 column 5 (char 74)
WARNING:root:1
INFO:root:Attempting to compile static assets...
Failed! Check that the plugin JSON config file located at /Users/ccesari/projects/GeositeFramework/src/GeositeFramework/sample_plugins/identify_point/plugin.json matches the required schema. Additional properties are not allowed (u'cssp' was unexpected)
Failed validating u'additionalProperties' in schema:
{u'$schema': u'http://json-schema.org/draft-03/schema#',
u'additionalProperties': False,
u'properties': {u'css': {u'items': {u'type': u'string'},
u'type': u'array'},
u'use': {u'type': u'object'}},
u'title': u'Geosite plugin configuration',
u'type': u'object'}
On instance:
{u'cssp': [u'sample_plugins/identify_point/main.css'], u'use': {}}
WARNING:root:1
Cool, looks like enough that an admin could debug, perhaps with some tech help from local staff. Is it possible to decode the strings in a way that doesn't prepend the unicode literal, might cut down on the noise nicely if it's not a ton of work.
Good suggestion regarding the u'
. Looking for a way to get rid of it.
Okay, pushed some more fixups. Despite repeated attempts, I couldn't get rid of the u'
. I did get rid of some of the extraneous details in the error messages, while still leaving enough detail to point out the error. Here are the updated messages.
INFO:root:Attempting to compile static assets...
Failed! Check that your region.json config file is properly formatted. Expecting , delimiter: line 3 column 5 (char 27)
ERROR:root:Exiting before compiling static assets.
INFO:root:Attempting to compile static assets...
Failed! Check that your region.json config file matches the schema. 1 is not of type u'string'
ERROR:root:Exiting before compiling static assets.
INFO:root:Attempting to compile static assets...
Failed! Check that the plugin JSON config file located at /Users/ccesari/projects/GeositeFramework/src/GeositeFramework/sample_plugins/identify_point/plugin.json is properly formatted. Expecting , delimiter: line 5 column 5 (char 74)
ERROR:root:Exiting before compiling static assets.
INFO:root:Attempting to compile static assets...
Failed! Check that the plugin JSON config file located at /Users/ccesari/projects/GeositeFramework/src/GeositeFramework/sample_plugins/identify_point/plugin.json matches the required schema. Additional properties are not allowed (u'cssp' was unexpected)
ERROR:root:Exiting before compiling static assets.
Thanks for the reviews! Rebased and merging.
Overview
Migrates the C# code responsible for assembling the instance plugins, validating their contents, and setting them up for use in the instance. A lot of the code is a direct port of the C# code. Some refactoring is also done along the way.
See commit messages for details.
Connects #1090
Demo
Currently plugin data is printed to the log
When a plugin has malformed configuration data
When a plugin has configuration data that doesn't match the schema
When a plugin folder is missing main.js
Testing Instructions
./scripts/create_static.py
locally and on Docker. Ensure the correct error messages shown.