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

Fix Spurious Compilation Errors #3845

Merged
merged 3 commits into from
Dec 2, 2024
Merged

Conversation

kaeluka
Copy link
Contributor

@kaeluka kaeluka commented Nov 27, 2024

Closes #3220

issue: https://github.com/github/codeql-core/issues/4654

This notifies the language server of newly downloaded packs once a pack is added to the current ql pack, or a pack's dependencies are installed.

This is the user facing behaviour I observed:

  • ✅ creating a query pack and example.ql file using the skeleton wizard:
    • works as expected
  • ✅ creating a query pack and ql file manually, then installing the ql pack's dependencies using the vs code command palette:
    • works: this removes the spurious compilation errors, even in open files.
    • ⚠️ the price of supporting that is that we restart the language server each time a pack is added or a pack's dependencies are installed. There might be cheaper solutions, but I don't know them. If the reviewers don't know of a cheaper solution: I think this overhead is worth it because pack add/pack install are rare operations and the user would likely have to manually restart or reload vs code instead to make it work.

Dear Reviewer

  • This is a PoC that works for me.
  • I had to inject the language server reference into the cli server.
    • I'm not sure if this would be considered a design violation. I'd appreciate some feedback.
    • If that's a problem, I could refactor this to break the dependency using dependency injection. Meaning: pass in a lambda function that does the notification.
  • Maybe, the same effect could also be achieved by different means (like watching the ~/.codeql/packages subdirectories, ...). Chances are, there's room for improvement.

@kaeluka kaeluka requested review from a team as code owners November 27, 2024 13:38
@kaeluka kaeluka force-pushed the kaeluka/4654-fix-spurious-errors branch 2 times, most recently from 656363b to a97fbd6 Compare November 27, 2024 14:32
@kaeluka kaeluka force-pushed the kaeluka/4654-fix-spurious-errors branch from a97fbd6 to 9c87113 Compare November 27, 2024 14:36
@kaeluka kaeluka marked this pull request as draft November 28, 2024 13:42
@kaeluka
Copy link
Contributor Author

kaeluka commented Nov 28, 2024

Koen pointed out this could be generalized: https://github.com/github/codeql-core/issues/4654#issuecomment-2506073240 -> draft mode

@kaeluka kaeluka force-pushed the kaeluka/4654-fix-spurious-errors branch from 9c87113 to 788bb4c Compare November 28, 2024 14:45
@kaeluka kaeluka marked this pull request as ready for review November 28, 2024 15:00
@kaeluka kaeluka marked this pull request as draft November 28, 2024 15:05
@kaeluka kaeluka force-pushed the kaeluka/4654-fix-spurious-errors branch from 788bb4c to 6fd3d20 Compare November 29, 2024 08:32
@kaeluka kaeluka marked this pull request as ready for review November 29, 2024 08:37
Copy link
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few small comments, but I'll leave a full review of this approach to someone that is more familiar with the language server/CLI interactions.

extensions/ql-vscode/src/codeql-cli/cli.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/codeql-cli/cli.ts Outdated Show resolved Hide resolved
@kaeluka
Copy link
Contributor Author

kaeluka commented Nov 29, 2024

Thank you for your comments <3 I'll work on them next week.

@kaeluka
Copy link
Contributor Author

kaeluka commented Dec 2, 2024

Thanks @koesie10 and @aeisenberg for your reviews! They've increased my confidence, as well as made the PR shorter and simpler :) This commit is the result: 17542d1

Copy link
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM! I've also tested this using the reproduction steps in the public and internal issues and it doesn't show any compilation errors once the pack has been installed.

Can you please add "Closes #3220" to the issue description since this PR fixes that issue?

@kaeluka
Copy link
Contributor Author

kaeluka commented Dec 2, 2024

I've also tested this using the reproduction steps in the public and internal issues and it doesn't show any compilation errors once the pack has been installed.

Thanks for taking the time to do that, I appreciate it!

Can you please add "Closes #3220" to the issue description since this PR fixes that issue?

done!

@kaeluka kaeluka merged commit d03b348 into main Dec 2, 2024
29 checks passed
@kaeluka kaeluka deleted the kaeluka/4654-fix-spurious-errors branch December 2, 2024 10:30
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.

Creating skeleton query pack shows spurious CodeQL compilation errors
3 participants