-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: Check malformed path entries #303
Conversation
eb3f71f
to
e2ab421
Compare
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.
Thanks for this. Just a couple of minor changes to make, then it'll be good to go.
_appmap/configuration.py
Outdated
has_separator = '/' in path or '\\' in path | ||
raise AppMapPackagePathException( | ||
f"Malformed path value '{path}' in configuration file. " | ||
"Path entries should be module names" |
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.
"Path entries should be module names" | |
"Path entries must be module names" |
_appmap/configuration.py
Outdated
def _check_path_values(self): | ||
for item in self._config["packages"]: | ||
path: str = item.get("path") | ||
if path and not self._check_path_value(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.
This code should also raise an exception if path
is None
. This case is currently not handled well, and produces an ugly error message.
3f22958
to
6db2a85
Compare
I gave these changes a try. Because of the way
So, we need to change this. When an invalid |
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.
6db2a85
to
8537fff
Compare
Done |
invalid_items.append(item) | ||
continue | ||
|
||
if len(invalid_items) > 0: |
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.
What's going to happen if this eliminates all the path entries?
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, no package will be instrumented, unless there are some dist
entries. We reach this state with at least one warning.
Thinking again, while loading the config file should we also check if:
packages
is a yaml sequence and not a scalar,packages
is empty,- every item has
path
XORdist
key?
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.
No, let's not expand the scope of this beyond checking that path
s are modules.
However, please add a test that has only invalid path
s, and confirm that the resulting Config
has a package
with an empty list of paths
.
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.
Done
8537fff
to
6cbf90e
Compare
Update Config so it matches the singleton style of Env.
6cbf90e
to
8f89354
Compare
8f89354
to
f7937ee
Compare
Fixes #302
Warning and dropping malformed configuration file package path entries, which cannot be parsed as Python module names:
.
mod1/mod2
,mod1\mod2
,123
,.
,