Skip to content

fix(importers): stop doubling the (scan_type) suffix in dynamic Test Type names#15149

Open
Maffooch wants to merge 1 commit into
bugfixfrom
fix-generic-import-test-type-doubling
Open

fix(importers): stop doubling the (scan_type) suffix in dynamic Test Type names#15149
Maffooch wants to merge 1 commit into
bugfixfrom
fix-generic-import-test-type-doubling

Conversation

@Maffooch

@Maffooch Maffooch commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Shortcut: sc-13441

Summary

Fixes a bug report: Generic Findings Import created doubled Test Type names such as Prisma Cloud (Generic Findings Import) Scan (Generic Findings Import).

Dynamic-test-type parsers (Generic, SARIF, and ~9 others) build the Test_Type name by appending Scan ({scan_type}) to the report's type field. The composition was not idempotent: when type already ended with the ({scan_type}) suffix, it was appended again, producing the doubled name.

What changed

  • resolve_dynamic_test_type_name() (new): single, idempotent name resolver. A type already ending in ({scan_type}) is used verbatim; everything else keeps the intentional {type} Scan ({scan_type}) format (so Tool1Tool1 Scan (Generic Findings Import), and SARIF is unchanged).
  • legacy_dynamic_test_type_name() (new): reproduces the pre-patch name. The reimport validation accepts either the new or the legacy name, so reimports into tests created with the old doubled name keep working — no data migration, no new Test type mismatch errors.
  • Docs: corrected generic_findings_import.md, OS__tests.md, PRO__tests.md, file/generic.md, and added the idempotency rule to OS__asset_hierarchy.md. The old docs described a {Test Name} (Generic Findings Import) format the code never produced, which is what set the customer's expectation.

Testing

TDD (failing test first, confirmed red reproducing the doubled name, then green):

  • New fixture unittests/scans/generic/generic_test_type_suffix.json + 3 regression tests: no-doubling on import, idempotent reimport, and pre-patch doubled-name reimport still works.
  • Full importer module (43), SARIF parser (25), and deduplication (50) suites pass; ruff clean.
  • HTTP e2e on a running instance: type: "Prisma Cloud (Generic Findings Import)"Prisma Cloud (Generic Findings Import) (no doubling); type: "Tool1E2E"Tool1E2E Scan (Generic Findings Import) (unchanged); reimport → HTTP 201, no mismatch.

🤖 Generated with Claude Code

@Maffooch Maffooch requested a review from mtesauro as a code owner July 3, 2026 18:01
@github-actions github-actions Bot added docker New Migration Adding a new migration file. Take care when merging. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 docs unittests ui parser helm labels Jul 3, 2026
…Type names

Generic Findings Import (and other dynamic-test-type parsers like SARIF)
built the Test Type name by unconditionally appending " Scan ({scan_type})"
to the report's `type` field. When `type` already carried the
" ({scan_type})" suffix, the suffix was doubled, e.g.
"Prisma Cloud (Generic Findings Import) Scan (Generic Findings Import)".

Extract the name resolution into resolve_dynamic_test_type_name(), which is
now idempotent: a `type` already ending in " ({scan_type})" is used verbatim.
The intentional "{type} Scan ({scan_type})" format is unchanged for all other
cases (Tool1 -> "Tool1 Scan (Generic Findings Import)"), preserving SARIF and
existing behavior.

To avoid breaking existing data, the reimport validation accepts either the
new idempotent name or the legacy (pre-patch) name via
legacy_dynamic_test_type_name(), so reimports into tests whose test_type was
created with the old doubled name keep working without a mismatch error.

Also corrects the Generic Findings Import docs, which described a
"{Test Name} (Generic Findings Import)" format the code never produced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Maffooch Maffooch force-pushed the fix-generic-import-test-type-doubling branch from 34b912b to 68f4cbe Compare July 3, 2026 18:22
@github-actions github-actions Bot removed docker New Migration Adding a new migration file. Take care when merging. settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 ui parser helm labels Jul 3, 2026

@valentijnscholten valentijnscholten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does auto create context need to be aware of old and new formats?
Does deduplication need to be aware of this? Probably not as the get_or_create ensures that if an old format test_type exists it will not create a new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants