github / vscode-codeql

An extension for Visual Studio Code that adds rich language support for CodeQL

Home Page:https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-codeql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variant Analysis Results fails to show results if query message contains placeholder which is not part of source

Marcono1234 opened this issue · comments

Describe the bug
When a query contains a placeholder in the query message ($@), and the results of a Variant Analysis run have a value for that placeholder which is not part of the source of a project, then the Variant Analysis Results view fails to show results.

Additionally the following is logged in the extension log:

Error when processing SARIF result: TypeError: Cannot read properties of undefined (reading 'startLine')

Version
Extension version

CodeQL extension version: 1.8.8 
CodeQL CLI version: 2.14.0 
Platform: win32 x64

VS Code version

Version: 1.80.1 (user setup)
Commit: 74f6148eb9ea00507ec113ec51c489d6ffb4b771
Date: 2023-07-12T17:22:07.651Z
Electron: 22.3.14
ElectronBuildId: 21893604
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.19045

To reproduce

  1. Open Quick Query and paste the following query
    /**
     * @kind problem
     */
    
    import java
    
    // Pick arbitrary element which is part of source; chose EnumType here because projects
    // likely don't have that many enum types
    // TypeString comes from the JDK and is not part of the source of the project
    from EnumType t, TypeString notPartOfSource
    where t.fromSource()
    select t, "message $@", notPartOfSource, notPartOfSource.getName()
  2. Run Variant Analysis, for example on the top 10 repositories
  3. On the Variant Analysis Results view click the triangle to expand the results
    ❌ Bug: No results are shown and an error is logged

Expected behavior
Results should be shown, but if the placeholder value is not part of the source, there should simply not be a link.

(Also: Maybe in general if an error while processing the SARIF result happens, the complete stack trace should be printed to the log to make debugging easier?)

Thank you for reporting this. I've also been able to reproduce the missing results when one of the placeholder values is not from the source archive. I get the error Error when processing SARIF result: TypeError: Cannot read properties of undefined (reading 'startLine') when trying to expand the results.

This issue is very closely related to #2629, though perhaps not entirely the same because the results are present but just fail to display. In that issue the results that are not from the source are completely omitted.

We've got an internal issue to track this, but we'll report here when there's any progress on this.

This should be fixed now. It will be available in the next extension release, which is likely to happen sometime next week.