Skip to content

fix: guard isTestoFile against invalid VirtualFile#52

Merged
xepozz merged 3 commits into
mainfrom
claude/fix-outdated-stub-index-X6jfP
May 15, 2026
Merged

fix: guard isTestoFile against invalid VirtualFile#52
xepozz merged 3 commits into
mainfrom
claude/fix-outdated-stub-index-X6jfP

Conversation

@xepozz
Copy link
Copy Markdown
Contributor

@xepozz xepozz commented May 15, 2026

TestoIconProvider could trigger an "Outdated stub in index" exception when invoked on a stale PsiFile whose underlying physical file no longer existed (e.g. a deleted vendor/autoload.php still cached in the stub index). isTestoFile() walked the AST via PsiTreeUtil before any validity check, forcing AST load and crashing on the stub mismatch.

Short-circuit isTestoFile() if the file is not a PhpFile, has no VirtualFile, or its VirtualFile is no longer valid - avoiding any PSI traversal in those cases.

claude added 2 commits May 15, 2026 08:59
TestoIconProvider could trigger an "Outdated stub in index" exception
when invoked on a stale PsiFile whose underlying physical file no
longer existed (e.g. a deleted vendor/autoload.php still cached in the
stub index). isTestoFile() walked the AST via PsiTreeUtil before any
validity check, forcing AST load and crashing on the stub mismatch.

Short-circuit isTestoFile() if the file is not a PhpFile, has no
VirtualFile, or its VirtualFile is no longer valid - avoiding any PSI
traversal in those cases.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2026.1.0
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

The original report showed an "Outdated stub in index" exception
triggered by isTestoFile() called on a stale PsiFile from vendor/ -
where the physical file was already deleted but the VFS hadn't
refreshed yet, so virtualFile.isValid still returned true.

A bare isValid check is therefore not enough. To make isTestoFile()
robust:

- Skip files outside project content (ProjectFileIndex.isInContent),
  excluded folders and IDE-ignored paths - this filters out vendor/
  and similar locations before any PSI traversal happens, removing
  the root cause for the reported case.
- Wrap the AST-loading traversal in a try/catch that rethrows
  ProcessCanceledException and downgrades any other Throwable
  (including StubTreeAndIndexUnmatchCoarseException) to a logged
  warning + false, so a transient index inconsistency can no longer
  propagate as an unhandled exception through callers (live
  templates, inspection suppressor, run config producer, etc.).
@xepozz xepozz merged commit 5447b00 into main May 15, 2026
3 of 4 checks passed
@xepozz xepozz deleted the claude/fix-outdated-stub-index-X6jfP branch May 15, 2026 09:57
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

Successfully merging this pull request may close these issues.

2 participants