Skip to content
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

Unknown AnalysisClassHierarchy.Untracked(_) exception occurs at analysis #378

Closed
gasharova opened this issue Feb 7, 2021 · 4 comments
Closed

Comments

@gasharova
Copy link

Hello, urgently trying to find a fix for an unidentified and undocumented error.
Running pysa analysis and getting this error:

ƛ Uncaught exception:
ƛ 
ƛ   AnalysisClassHierarchy.Untracked(_)
ƛ 
ƛ Raised at file "string.ml", line 115, characters 19-34
ƛ Called from file "src/sexp.ml", line 113, characters 13-47
ƛ Client exited with error code 1```

pyre config file:

{
  "source_directories": [
    "."
  ],
  "taint_models_path": ".",
  "exclude": "/home/zeus/work/test-protecc/env/lib/python3.9/.*"
}

Our model:

model_content = """
protecc.vortex.Vortex.SECRETS: TaintSource[Secret]
protecc.vortex.Vortex.endpoints: TaintSink[Endpoint]
"""

The class its modelling:

...
class Vortex:
    def __init__(self):
        self.SECRETS = {}   # Populate with sources
        self.endpoints = set() # Populate with sinks
...

We tried tweaking a lot of things and we keep getting the same error.
Only found 3 mentions of this problem so far here, here at the end of the page and also here. None have been useful so far.

@gbleaney
Copy link
Contributor

gbleaney commented Feb 8, 2021

@AngelinaG we're going to do some work to make that error message a lot more helpful. Thanks for pointing this out.

In the mean time, your attempt at excluding your venv in via taint.config seems like the right approach, because odds are it's something in the venv that's causing the exception. I wonder if the exclude isn't working though. To test that, can you try two different approaches:

  1. Update the exclude to something like .*/env/.*
  2. Just remove the venv from the project you're analyzing entirely

If you're still getting errors after trying both of those, perhaps the problematic code really is present in your project. If that's the case, can you try doing a sort of binary search for the bug by deleting one half the code and then the other, and seeing if it makes the error go away? If you find the problematic file/lines, we can use that as a test case to get a fix out for you.

facebook-github-bot pushed a commit that referenced this issue Feb 8, 2021
Summary:
The basic premise here is that our ClassHierarchy.Untracked issue gets surfaced to users a decent amount, and has come up on GitHub during the type checking multiple times: #378 as the most recent example. OCaml isn't able to serialize Type.t's to user, but can do a better job with strings, especially when we're in the case of a `Scheduler.map_reduce`, where the backrtrace can be very hard to read.

For reference, here's what the exceptions have historically looked like:

```
AnalysisClassHierarchy.Untracked(_)
```

This diff changes the type of `ClassHierarchy.Untracked` to take a string, so that users at least know which type caused the issues. This isn't perfect, but can give us enough information to help do some basic debugging.

Consequences:

The good:

1. We get more readable error messages for some of the harder-to-debug errors we tend to find.

2. We've eliminated a lot of the Type.show's, since all we did with this exception type was display it.

The bad:

1. Analysis failure errors of different types will not be joined any more. I don't think this is a real concern.

2. The types of analysis failures are no longer dequalified. I think this is the real concern, but in this case, feel that the benefit of users being able to debug this outweighs the longer error message.

Reviewed By: grievejia

Differential Revision: D26323785

fbshipit-source-id: b63b626005c2b14246534373825b68f9a2e96784
@SaurusXI
Copy link

@gbleaney I'm a part of this project also. I've got an update on this - turns out the problem was within our own library, specifically a misplaced import statement.
As you've already mentioned, the issue here is that there is no meaningful exception that can help with debugging. I might have a helpful suggestion for this - I was able to identify what was wrong by running a pyre server in the project directory. That gave a much more meaningful unable to find module ... exception.
I'm not sure if this can be generalized to dealing with all AnalysisClassHierarchy.Untracked(_) exceptions, or even if it is the most helpful way of doing this, but as far as I know pyre analyze also runs the pyre type checker, so it might be possible to propagate exceptions from the type checker?

@gbleaney
Copy link
Contributor

@SaurusXI is there any way you could put that into a small file I could use to repro? From what you were describing, I assumed adding an import thispackagedoesnotexist would triger the bug, but it appears it doesn't.

@arthaud
Copy link
Contributor

arthaud commented Apr 19, 2021

We have improved that specific exception, it should now give the problematic class. I will close this for now, feel free to reopen if you still have issues.

@arthaud arthaud closed this as completed Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants