-
Notifications
You must be signed in to change notification settings - Fork 663
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
False positives related to UndefinedClass #6517
Comments
When you say you tried with --no-cache, you mean that the issue is reproduced in your CI event when not using cache? Can you try with --threads=1 ? Do you see what those classes may have in common? |
Yes, everything I listed in the issue description I tried and the issue is still reproduced in the CI environment but not the local dev environment. I can't see anything that the classes have that is not in plenty of other classes throughout the codebase as well (and even in the same namespace). FYI they're Doctrine entities, so they have a bunch of properties with annotations, a constructor, a bunch of getters/setters and some other domain functions but they're pretty light. All the other entities have all this as well. I've tried with |
IIRC, debug also puts the number of threads to 1. This means it's a concurrency issue. It may also be the reason why your local environment doesn't reproduce (either because you're on windows or in an environment that doesn't allows threads or a different number) It may be because of a cyclic dependancy but I have no idea how Psalm handle that kind of things... |
Oh right, that makes sense. Do you have any idea how I could debug this further? FWIW my dev environment is ubuntu 18.04 and CI is running on a docker container based off node:12-stretch. |
I've also tried deleting everything out of the offending classes so they're just an empty class, but this still causes the error. |
I'm not sure, I'd try experimenting with the number of threads to see if there's a sweet spot with as many threads as possible without crashing. I'm not sure if --debug-by-line works alongside with threads but if it does, maybe check the order of classes analysis when it crash opposed to when it doesn't crash. I'm not sure what you could do even if you get this information though |
Thanks for the help. It seems that I'll keep digging into the debug output to try identify the root cause, but might take a while. Update: |
I've run with
When the issue is reproduced, there are 2 classes that result in With
1 and 2 always happen immediately after each other, as do 4 and 5. Although the order in which entity is processed can change.
But in the next build, EntityB might come first:
The order doesn't really seem to matter IMHO, since the issue is very consistent but the order is not. Even their order compared to other classes is different across all builds. Although I haven't broken down the order of every class because there's way to many to make much sense of that. Additionally, for each of the classes the following errors are identified by psalm when the issue is reproduced:
After digging through this for a while, I cannot identify anything that seems to be the root cause. Not sure if any of the above give you any ideas as to where to dig further? Happy to share the logs privately if you think that will help? Just flick me your email address on LinkedIn or something. |
Does adding or removing an entity change anything? |
Adding an entity doesn't change anything. Removing the entities that cause the problem result in even more of the same errors (ie. UndefinedClass, etc). Which seems to mean that psalm is able to find the class sometimes and not others. |
I am also experiencing the same issues where specific classes are found 'undefined' in CI (specifically Bitbucket Pipelines), while tests pass perfectly fine on local environment. I have tried increasing memory, adding I'll try adding the The issue i's also not specific to Doctrine, because I'm experiencing this on a Magento 2 project. |
Do you use anything out of ordinary? Plugins, Stubs, autoloader...? |
I'm using the doctrine plugin and just the ordinary composer autoloader. No custom stubs (besides the doctrine plugin). |
I believe we are also affected by this, and the
We are using no psalm plug-ins on this product, (Symfony 3.x codebase) Macbook Pro M1 running in PHP 8.1, although also happening within docker images built
Re-running psalm successively in a script 10x times will lead to different number of errors outputted each time.
x10 will result in
The extra errors reported are typically:
Posting as it might help others and as a 'me too', but I appreciate it might not be enough to debug |
@kieljohn I'd be interested to know if you can reproduce on our master branch (which will soon be released as Psalm 5). There has been some internal changes that can prevent some multithreading issues, it may resolve this hopefully |
Experiencing the same issue on psalm 5.4 but in reverse where CI is fine, but locally the same class (every time) is undefined. Having read the comments here, running Disabling plugins had no effect. Issues reported are consistent every time. My baseline is empty, but removing it from config also had no effect. |
Experiencing a similar issue in 5.17. Very hard to reproduce. Seems like psalm fails to load some classes when caching is enabled and there's cached data. |
Over the past week, Psalm in our CI build has been returning a lot of errors related to
UndefinedClass
.It's always related to the same one or two classed that it thinks are undefined, however they are not.
I've fully checked the path to the classes multiple times and they definitely exist, in the right place, with the right character cases in their FQCN and path. Additionally, the app successfully loads the classes all the time and I've written a short script that requires the autoloader and instantiates the classes that psalm can't find which I run right before running psalm.
I'm unable to reproduce this in my local dev environment, but it's very consistent in the CI environment. I also can't seem to make any sort of reproducer.
I've tried:
autoloader
and not specifying it at all inpsalm.xml
--no-cache
composer dump-autoload
andcomposer dump-autoload -o
before running psalmFrom the couple of classes it cannot find, it generates a bunch of other errors such as
MoreSpecificReturnType
,LessSpecificReturnType
,MixedInferredReturnType
,UndefinedDocBlockClass
,MixedMethodCall
,MixedInferredReturnType
, etc. I believe these all stem from not being able to determine the type of the objects because their class is "undefined".Our codebase is very modern and we've been using psalm from day 1, so it's not like we have a custom autoloader or anything weird. I know that it will be very hard for anyone to track this down and I'm certainly very happy to do the work. But I have no idea where to go now in order to debug further.
The text was updated successfully, but these errors were encountered: