Skip to content

Conversation

@andrewrobinsonhodges-snyk
Copy link
Contributor

Description

This PR fixes two issues with the delta scan issue counts, and adds more robust logging so we can debug these issues more easily in the future.

  1. Issue caches were not getting cleared when reference branches/folders were being set. As the cache was only populated after a scan completes, this meant that changing a base/reference branch/folder would potentially give different results depending on whether or not the new base/reference branch/folder had been scanned before.

  2. When we enrich issues with isNew after a delta scan, we set isNew to true if they were in the diff, however we did not set isNew to false if they were not in the diff. Depending on the order of scans and base/reference branch changes, the same issue list could be diffed multiple times, giving different results as it would contain old state.

Checklist

  • Tests added and all succeed
  • Regenerated mocks, etc. (make generate)
  • Linted (make lint-fix)
  • [n/a] README.md updated, if user-facing
  • [n/a] License file updated, if new 3rd-party dependency is introduced

@snyk-io
Copy link

snyk-io bot commented Dec 5, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @andrewrobinsonhodges-snyk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical inaccuracies in delta scan issue counts by ensuring that cached scan results are properly invalidated and that the 'isNew' status of issues is correctly determined. It also significantly improves the observability of the delta scanning process through comprehensive logging, enhancing the reliability and debuggability of the feature.

Highlights

  • Delta Cache Clearing: The system now correctly clears the persisted scan cache for a folder when its base branch or reference folder path changes. This prevents stale delta scan results from being used.
  • Corrected 'isNew' Flag Logic: The logic for enriching issues with the 'isNew' flag has been fixed. Issues that are no longer present in the current scan's diff are now explicitly marked as 'isNew: false', resolving a bug where old issues could incorrectly retain a 'new' status.
  • Enhanced Logging for Debugging: Extensive debug and info level logging has been added across the persistence layer, scanner, and product-specific scanners. This provides much greater visibility into the delta scan process, cache operations, and issue enrichment, making future debugging significantly easier.
  • Improved Delta Matching Robustness: New test cases have been introduced to ensure the delta calculation correctly identifies identical issues even when their content roots differ (e.g., between a temporary base branch directory and the working directory), preventing false positives for 'new' issues.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves two key issues concerning incorrect delta scan issue counts and enhances logging for improved future debugging. The first fix correctly invalidates issue caches upon changes to reference branches or folders. The second fix refines the logic for marking issues as new, ensuring that issues no longer present in the delta are appropriately updated. The introduction of more detailed and structured logging is a commendable improvement for observability. The added tests are thorough, particularly those for cache clearing and cross-directory diffing. I've identified a minor logging format issue in internal/vcs/checkout_handler.go and have provided suggestions for correction.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Contributor

@rrama rrama left a comment

Choose a reason for hiding this comment

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

LGTM. I think I wrapped my head around "new", "base", "current", "delta", etc.

@andrewrobinsonhodges-snyk andrewrobinsonhodges-snyk merged commit 02a17a8 into main Dec 8, 2025
18 checks passed
@andrewrobinsonhodges-snyk andrewrobinsonhodges-snyk deleted the fix/IDE-1514_delta_issue_counts_incorrect branch December 8, 2025 17:38
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.

4 participants