-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
521 notice parcing failure #586
Conversation
And I can't see exactly which error in pretty big Travis feed fails. Never used tests in Python, sry. |
Hi @RollingHog, thanks for your changes. I would see it implemented a bit differently:
Regarding the tests, you can run them using the follwing command from |
Oookay. |
Will update this during work
Kinda. Not sure what is "shown as read" |
Questions emerged:
|
…led link implementation
Yes please, please check the file (I think regex is not needed, just check, that the file content contains "allowed_users" string) |
For the stacktrace, I would suggest to log it. It will cause some noise, but it's easier to investigate having traceback |
I meant only for "cannot parse" error of course. Still log? And about files. I think a note "some file with restricted access is malformed" will be good, wont it? Or there is some reason to fully hide this info? |
yes, it can still provide some hints on what's wrong with the file.
Not for normal users. Any restricted information should be hidden from users, to avoid any leaks. Even if it's only a file name |
No no no! What I planned to do was replacing filename with "file with possibly restricted access" server-side. So users see that something is wrong (and can eg notify admin) but don't know what exactly.
You mean that error message about exact line where problem is? Okay. |
Ah, I see. I thought, that you wanted to display filename and show the error
|
All done. Now trying to understand testing command output to fix the tests. |
@@ -191,7 +196,10 @@ def load_script(path, content): | |||
return None | |||
|
|||
return short_config | |||
except: | |||
except json.decoder.JSONDecodeError: |
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.
Please add logging for the error, to help admin debugging the issue.
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.
Isn't logging already present there?.. Line 200. It provides all info including exact mistake in JSON grammar.
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 believe I wrote the comment, before you added the logging :) thanks
src/config/config_service.py
Outdated
if name == path: | ||
failed_short_config = create_failed_ShortConfig(path) |
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 believe that we should do smth like:
failed_short_config = create_failed_ShortConfig(path)
if name == failed_short_config.name:
...
I.e. we shouldn't compare the path to the name directly, because the name doesn't contain .json
extension and there can be some other rules in the future
.scripts-list .collection-item .menu-item-state.finished > .check-icon { | ||
display: block; | ||
} | ||
|
||
.scripts-list .collection-item .menu-item-state.finished > .preloader-wrapper { | ||
.scripts-list .collection-item .menu-item-state.finished > .preloader-wrapper, | ||
.scripts-list .collection-item .menu-item-state.finished > .failed-icon { |
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 there is no need to duplicate this display:none
multiple times.
You can define it once, smth like:
.scripts-list .collection-item .menu-item-state > .failed-icon {
display: none;
}
And it should be enough.
I do not know why I copied it multiple times for check icon and preload wrapper.
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.
Not sure what to do with that, sorry.
if (error.code === 422) { | ||
commit('SET_ERROR', `${CANNOT_PARSE_ERROR_PREFIX} "${selectedScript}"`); | ||
return; | ||
} |
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 would suggest to remove custom handling here. Script server can start sending 422 for other cases as well, so always showing "parsing error" is not good. We should always rely on error.reason
, which is provided by the server
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.
Okay, how should I aquire that error then?
Co-authored-by: Iaroslav Shepilov <buggygm@gmail.com>
Co-authored-by: Iaroslav Shepilov <buggygm@gmail.com>
…ngHog/script-server into 521-notice-parcing-failure
bugy#586 made some code review fixes for failed parsing feature
@@ -191,7 +196,10 @@ def load_script(path, content): | |||
return None | |||
|
|||
return short_config | |||
except: | |||
except json.decoder.JSONDecodeError: |
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 believe I wrote the comment, before you added the logging :) thanks
src/config/config_service.py
Outdated
failed_short_config = create_failed_short_config(path) | ||
return failed_short_config |
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.
failed_short_config = create_failed_short_config(path) | |
return failed_short_config | |
return create_failed_short_config(path) |
src/config/config_service.py
Outdated
except json.decoder.JSONDecodeError: | ||
if name == path: | ||
failed_short_config = create_failed_ShortConfig(path) | ||
raise StopIteration(ConfigSearchResult(failed_short_config, path, None)) |
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.
Not done. The exception won't be thrown here. What I meant is to add the following code after
configs = self._visit_script_configs(find_and_load)
if(search_result.short_config.parsing_failed == True):
raise BadConfigFileException()
I.e. do it only once in _find_config
, instead of duplicating it in load_config_model
and load_config
src/model/script_config.py
Outdated
|
||
def create_failed_ShortConfig(path): | ||
failed_short_config = ShortConfig() | ||
failed_short_config.name = path |
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.
Not done
src/model/script_config.py
Outdated
failed_short_config.name = path | ||
with open(path) as f: | ||
if '"allowed_users"' in f.read(): | ||
failed_short_config.name = 'file with possibly restricted access (path hash ' + hex(hash(path)) + ')' |
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.
Should we use some shorter name? 😅 Probably not longer than 20 characters
src/web/script_config_socket.py
Outdated
@@ -184,6 +184,9 @@ def load_model(): | |||
except ConfigNotAllowedException: | |||
self.close(code=403, reason='Access to the script is denied') | |||
return None | |||
except BadConfigFileException: | |||
self.close(code=BadConfigFileException.HTTP_CODE, reason=BadConfigFileException.VERBOSE_ERROR) |
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.
As discussed, please use exception.message here
<router-link :to="script.path" append | ||
:key="script.name" |
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.
<router-link :to="script.path" append | |
:key="script.name" | |
<router-link :to="script.path" | |
append | |
:key="script.name" |
@RollingHog I'm so sorry, I totally forgot about this PR. I thought that we finished it. |
Well, I hope it helped. |
#521 adding notice for failed parsing
TESTS NOT FIXED, WAITING FOR OVERALL APPROVAL/CHANGES
UI changes:
conf/runners
.json files script-server cannot parse, red group called `` will appear in main scripts listBackend changes:
list_configs()
now returns mixedList[ Union[ShortConfig, GetShortConfigFailedError] ]
list which is filtered inGetScripts()
server.py
GetScripts()
endpoint - now returns JSON{'scripts': scripts, 'failed': failed}
where'failed'
is "failed parsing"Frontend changes (I had no idea what I'm doing):
ScriptFailedGroup.vue
closely resemblingScriptListGroup.vue
to show list of non-interactive unparsed files