Skip to content

Fix Session.delete() handling in gap analysis cleanup (#826)#827

Open
akashrajeev wants to merge 2 commits intoOWASP:mainfrom
akashrajeev:fix-gap-analysis-delete-count
Open

Fix Session.delete() handling in gap analysis cleanup (#826)#827
akashrajeev wants to merge 2 commits intoOWASP:mainfrom
akashrajeev:fix-gap-analysis-delete-count

Conversation

@akashrajeev
Copy link
Copy Markdown
Contributor

@akashrajeev akashrajeev commented Mar 26, 2026

Fixes #826

Summary

This PR fixes an issue with how cached gap analysis rows are deleted in delete_gapanalysis_results_for().

Previously, Session.delete() was used incorrectly, which caused unexpected behavior during the gap analysis cleanup process. This update corrects the logic to align with SQLAlchemy 2.x expectations and ensures proper deletion of cached results.

Note: This PR focuses only on the SQLAlchemy cleanup fix. The tiered Neo4j gap-analysis optimization work was already merged separately in #716, #717, and #748.

Changes

application/database/db.py

  • Fixed Session.delete() handling within delete_gapanalysis_results_for()
  • Ensured proper cleanup of gap analysis results

application/tests/db_test.py

  • Updated tests to cover gap analysis result cleanup
  • Improved coverage for associated logging

How to Test

  • Run test suite (focus on db_test.py)
  • Ensure all tests pass and CI is green

@akashrajeev akashrajeev force-pushed the fix-gap-analysis-delete-count branch from 8e344bd to 0cfa033 Compare March 26, 2026 18:10
@akashrajeev
Copy link
Copy Markdown
Contributor Author

Hi @Pa04rth @northdpole

Could you please take a look at this PR when you get a chance?

Would appreciate your feedback when you get a chance — happy to adjust anything if needed.

@PRAteek-singHWY
Copy link
Copy Markdown
Contributor

Hi @akashrajeev , thanks for working on this fix.

Quick note: the current PR summary seems to describe gap-analysis optimization/feature-flag work, while this PR’s actual diff appears to focus on Session.delete() handling in delete_gapanalysis_results_for() (Issue #826).

Could you please update the PR description so it matches the current code changes? That will make maintainer review smoother and avoid confusion.

Also for context, the tiered gap-analysis optimization track has already been implemented and merged in #716, #717, and #748 after discussion with @northdpole.

Requesting @Pa04rth and @northdpole to please take a look as well.

Thanks again.

@akashrajeev
Copy link
Copy Markdown
Contributor Author

akashrajeev commented Mar 29, 2026

Hi @PRAteek-singHWY ,

Thank you so much for pointing that out and for the clarification on the gap-analysis track! I've updated the PR description to accurately reflect the SQLAlchemy session usage fix in db.py.

I really appreciate you taking the time to help me get this right—let me know if there's anything else needed on my end!

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.

Fix incorrect Session.delete() result handling in gap analysis cleanup

2 participants