Skip to content

fix: dedupe management command FieldError with only("id") and select_related#14350

Merged
Maffooch merged 2 commits intoDefectDojo:bugfixfrom
valentijnscholten:fix/dedupe-command-select-related
Feb 23, 2026
Merged

fix: dedupe management command FieldError with only("id") and select_related#14350
Maffooch merged 2 commits intoDefectDojo:bugfixfrom
valentijnscholten:fix/dedupe-command-select-related

Conversation

@valentijnscholten
Copy link
Copy Markdown
Member

@valentijnscholten valentijnscholten commented Feb 19, 2026

Summary

  • Fix FieldError in async dedupe path: findings.only("id") raised a FieldError when select_related traversal was still active on the queryset. Clearing both select_related(None) and prefetch_related(None) before calling only("id") resolves this, making the async dispatch path work regardless of how the queryset was originally constructed.
  • Fix --dedupe_batch_mode flag: Changed from action="store_true" to action=argparse.BooleanOptionalAction so the flag can be explicitly disabled with --no-dedupe_batch_mode (previously it could only be enabled, not disabled at the CLI).

Using findings.only("id") while select_related traversal was still
active on the queryset caused a FieldError. Clear both select_related
and prefetch_related before calling only("id") so the async dispatch
path works regardless of how the queryset was constructed.

Also switch --dedupe_batch_mode from store_true to BooleanOptionalAction
so the flag can be explicitly disabled with --no-dedupe_batch_mode.
@valentijnscholten valentijnscholten changed the title fix: dedupe command FieldError with only("id") and select_related fix: dedupe management command FieldError with only("id") and select_related Feb 20, 2026
Copy link
Copy Markdown
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

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

Approved

@Maffooch Maffooch requested a review from rossops February 23, 2026 05:30
@Maffooch Maffooch merged commit a3c67b8 into DefectDojo:bugfix Feb 23, 2026
148 checks passed
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.

5 participants