Skip to content

fix: code references count returns 0 after unchanged rescan#7599

Merged
Zaimwa9 merged 2 commits into
mainfrom
fix/code-reference-update-in-conflict
May 26, 2026
Merged

fix: code references count returns 0 after unchanged rescan#7599
Zaimwa9 merged 2 commits into
mainfrom
fix/code-reference-update-in-conflict

Conversation

@Zaimwa9
Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 commented May 26, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

  • ignore_conflicts=True was skipping creating a new code reference record when scanning an unchanged code reference
  • We use a filter based on the last scanning created_at=F("repository__last_scanned_at") so while last_scanned_at advanced, there was no related code_reference on this date
  • Switched to update_conflicts=True with unique_fields and update_fields being created_at and revision (only ones updated on conflict)

Impact appeared starting from second scanning.

How did you test this code?

  • Updated test to also check the payload is properly returned after conflicting update

@Zaimwa9 Zaimwa9 requested a review from khvn26 May 26, 2026 13:55
@Zaimwa9 Zaimwa9 requested a review from a team as a code owner May 26, 2026 13:55
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview May 26, 2026 2:14pm
flagsmith-frontend-preview Ignored Ignored Preview May 26, 2026 2:14pm
flagsmith-frontend-staging Ignored Ignored Preview May 26, 2026 2:14pm

Request Review

@github-actions github-actions Bot added the api Issue related to the REST API label May 26, 2026
khvn26
khvn26 previously approved these changes May 26, 2026
Copy link
Copy Markdown
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM with a tiny nit

@github-actions github-actions Bot added the fix label May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-7599 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-7599 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-7599 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-7599 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7599 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7599 Finished ✅ Results

Copy link
Copy Markdown

@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 updates the code reference recording logic in record_scan to update conflicts on duplicate records instead of ignoring them. Specifically, it configures update_conflicts=True with unique fields ["feature", "repository", "code_references_hash"] and updates ["created_at", "revision"]. Additionally, the unit tests have been updated to verify that code references remain retrievable after handling duplicate payloads. I have no feedback to provide as there are no review comments.

Comment thread api/projects/code_references/services.py
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.51%. Comparing base (e39f9ae) to head (d254f06).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7599   +/-   ##
=======================================
  Coverage   98.51%   98.51%           
=======================================
  Files        1436     1436           
  Lines       54363    54382   +19     
=======================================
+ Hits        53553    53572   +19     
  Misses        810      810           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.1 seconds
commit  b099e35
info  🔄 Run: #17002 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.5 seconds
commit  b099e35
info  🔄 Run: #17002 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  50.6 seconds
commit  b099e35
info  🔄 Run: #17002 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 9 seconds
commit  b099e35
info  🔄 Run: #17002 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.7 seconds
commit  d254f06
info  🔄 Run: #17004 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.2 seconds
commit  d254f06
info  🔄 Run: #17004 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  42.7 seconds
commit  d254f06
info  🔄 Run: #17004 (attempt 2)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.7 seconds
commit  d254f06
info  🔄 Run: #17004 (attempt 2)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  42.4 seconds
commit  d254f06
info  🔄 Run: #17004 (attempt 2)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  46 seconds
commit  d254f06
info  🔄 Run: #17004 (attempt 2)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Visual Regression

19 screenshots compared. See report for details.
View full report

Copy link
Copy Markdown
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions github-actions Bot added fix and removed fix labels May 26, 2026
@Zaimwa9 Zaimwa9 merged commit 3fa3d9a into main May 26, 2026
44 of 52 checks passed
@Zaimwa9 Zaimwa9 deleted the fix/code-reference-update-in-conflict branch May 26, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants