Skip to content

Adding source files to workspace fails with "couldn't obtain file explorer uri for \<dbname\>" #1020

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

Closed
mkacymo opened this issue Nov 25, 2021 · 7 comments · Fixed by #1021 or #1025
Closed
Labels
bug Something isn't working VSCode

Comments

@mkacymo
Copy link

mkacymo commented Nov 25, 2021

Describe the bug
When trying to add sources from DB to Visual Studio workspace, the output log indicates a
"Couldn't obtain file explorer uri for <dbname>"
message, but the sources are not added to the file explorer view.
Queries work like a charm and are linked to sources that will open as expected.

The issue occurs on a bundled DB zip archive as well as on an unzipped archive that was added to VS as folder.
The db zip includes both, a src folder and an src.zip.
The dbbundle has been created using
codeql database create --language=cpp --command=make <dbname>
codeql database bundle --output=<dbname>.zip --include-uncompressed-source <dbname>
on a Linux host using codeQL CLI 2.7.0
VS Code is running on a Windows host in version 1.62.3 and CodeQL Extension 1.5.7 using CodeQL CLI 2.7.2

Version
VS Code is running on a Windows host in version 1.62.3 and CodeQL Extension 1.5.7 using CodeQL CLI 2.7.2
DB was created on a Linux host using codeQL CLI 2.7.0

To reproduce
create DB as above on linux host
copy bundled DB to analyzing windows host
start vscode-codeql-starter workspace
add database from archive (or from folder after unzipping it)
rightclick on database in codeql databases section
pick "add database source to workspace"

Expected behavior
Source files are added to workspace and are visible in file explorer

@mkacymo mkacymo added the bug Something isn't working label Nov 25, 2021
@aeisenberg
Copy link
Contributor

Apologies for the silly question, <dbname> is just a placeholder for the actual database name, right?

@mkacymo
Copy link
Author

mkacymo commented Nov 25, 2021

Hi, yes, sorry for the unclarity. Its just some regular dbname without any surprises (like special characters)

@aeisenberg
Copy link
Contributor

The "Add Database Source to Workspace" command only works on zipped source files. We should probably update the error message to make this more explicit. There are many extension features that don't work well on unzipped sources, but if you must use unzipped sources, then you can add the folder explicitly to your workspace by running Workspaces: Add folder to workspace

Is there a reason why you are passing --include-uncompressed-source? As mentioned it is easier to use the extension with zipped sources.

@mkacymo
Copy link
Author

mkacymo commented Nov 26, 2021

I added the --include-uncompressed-source flag to double ensure the db will include the sources. I checked the db archive and it includes both, zipped and uncompressed sources. I'll tried on a DB without this flag and it works like a charm.
If a DB generated with uncompressed sources cannot be used to access the sources in VS-Code I'd have the following suggestions/ideas

  • Actually there is no good reason that would avoid handling these dbs, as the original zipped sources are still included. So capabilities of handling DBs including both variants could potentially be detected and added by some minor changes.
  • Otherwise: Consider removing the redundancy. If a DB is suited either for extensions using compressed sources or extensions using uncompressed sources, there should be no need to ever include both variants in the zip file (if I understood correctly).
  • Adjust the description of the --include-uncompressed-source flag in the documentation to reflect that it's application will generate DBs not suited for extensions preferring zipped sources. It can currently easily be misread as "add this for compatibility for older extensions"
    Thanks for your kind support.

Shall I close the issue, or do you want to add any further follow up tasks first?

aeisenberg added a commit that referenced this issue Nov 29, 2021
…1021)

* Emit more relevant error message when failing to add source folder

Fixes #1020

* Update changelog

* Clarify changelog and error message

Co-authored-by: Shati Patel <[email protected]>

Co-authored-by: Shati Patel <[email protected]>
@aeisenberg
Copy link
Contributor

aeisenberg commented Nov 29, 2021

Hmmm...it should be the case that if a database has both a src folder and a src.zip archive, the latter takes precedence. Let me see what is happening here.

And, the --include-uncompressed-source is really a legacy option. There is no case for using it any more that I can think of, unless you are required to use the Eclipse plugin for CodeQL.

@aeisenberg
Copy link
Contributor

Ah...there is a bug here. The source folder is indeed being given priority over the source archive. I have a simple fix, which I will put up later. Thanks for helping me dig into this.

@mkacymo
Copy link
Author

mkacymo commented Nov 30, 2021

I have to thank for the super quick investigation and fixing =).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working VSCode
Projects
None yet
2 participants