Skip to content

fix(411): report missing non-match records instead of a clean document - #412

Merged
sromoam merged 2 commits into
devfrom
fix/411-html-false-success
Oct 19, 2026
Merged

sromoam merged 2 commits into
devfrom
fix/411-html-false-success

Conversation

@digalaviz

Copy link
Copy Markdown
Contributor

Pull Request

Issue Reference

Fixes #411

Description of Changes

The HTML report's Non-Matches Analysis section rendered No non-matches found. over a document with a failing field, for the same reason the terminal printers did before #404: nothing distinguished "records were never collected" from "records were collected and there were none".

Changes Made

  • DataExtractor.extract_non_matches returns Optional[List[...]]. None means no records were collected, [] means collected and empty. It no longer flattens ProcessEvaluation.non_matches is None or a missing dict key into [].
  • SectionGenerator.generate_non_matches renders a note for None naming document_non_matches=True, and keeps the success message for [].
  • tests/reporting/html/test_data_extractors.py had an assertion pinning the conflation (== [] for a ProcessEvaluation whose non_matches is None); it now asserts is None, with two cases added for the dict paths.
  • tests/reporting/html/test_html_non_match_records.py is new: 5 cases driving real compare_with() dicts and a real BulkStructuredModelEvaluator through SectionGenerator with no patching.
  • tests/reporting/html/README.md is new, documenting the directory's mocking boundary and the three record states.

Why These Changes Are Needed

compare_with() only writes the top-level non_matches key when called with document_non_matches=True, so the default comparison dict carries no records, and the absence of records is not evidence that nothing failed. Measured before this change, identical on f81a33e and on #404's head 2ca4fe0, for a prediction whose name scores 0.0:

non_matches key: False
name field score: 0.0
DataExtractor.extract_non_matches -> []
<div class="section"><h2>Non-Matches Analysis</h2><p>No non-matches found.</p></div>

After, on this branch:

DataExtractor.extract_non_matches -> None
<div class="section"><h2>Non-Matches Analysis</h2><p>No non-match records in these
results. Call <code>compare_with()</code> or the bulk evaluator with
<code>document_non_matches=True</code> to collect them.</p></div>

#404 closes the same defect for the terminal printers but does not touch this module, so without this the two reporters disagree and the HTML report is the one that gets shared. The three-state rule here matches the one #404 establishes; unifying the two extractors is out of scope and tracked by #137.

Every other test in tests/reporting/html/ patches DataExtractor.extract_non_matches, which is precisely the function at fault, so none of them could have caught this. That is why the new coverage builds results for real, and why the directory README now records the boundary.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • All existing tests pass

Full suite on this branch: 2914 passed, 12 skipped, 1 xfailed (2906 on dev e403b9b, plus the 8 added here). ruff check src tests: all checks passed. ruff format --check reports the two source files and the two edited test files, which it also reports unchanged on dev; the new file is clean, lint.yaml runs ruff check only, and reformatting them would add unrelated churn.

Checklist

  • Code follows the project's coding standards
  • Self-review of code completed
  • Documentation updated (if applicable)
  • CHANGELOG.md entry added under [Unreleased]
  • Tests added/updated for new functionality
  • All CI checks are passing
  • Ready for review

Additional Notes

DataExtractor.extract_document_ids also reads results.non_matches or [], left as is: it collects document IDs and an empty result there is not a claim about the document.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The HTML report's Non-Matches Analysis section rendered "No non-matches
found." for a compare_with() dict computed without document_non_matches=True,
including one whose name field scored 0.0, and for a bulk ProcessEvaluation
built with document_non_matches=False.

DataExtractor.extract_non_matches returned [] both when records had been
collected and were empty and when they were never collected, so the renderer
had nothing to distinguish them by. It now returns None for the second case and
the section says the records are missing and how to collect them. An empty list
still renders the success message.

tests/reporting/html/test_data_extractors.py pinned the conflation by asserting
[] for a ProcessEvaluation whose non_matches is None; that assertion is now
is None. Every other test in the directory patches the extractor, which is why
the defect survived them, so the new coverage drives real comparison dicts and a
real bulk evaluator through SectionGenerator without patching.
@digalaviz
digalaviz requested a review from sromoam as a code owner October 16, 2026 18:18
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

  • Report generated: 2026-10-19T21:58:06+00:00
  • Time since scan: 2 minutes

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-10-19T21:55:19+00:00
  • ASH version: 3.1.2

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

  • Severity levels:
    • Suppressed (S): Findings that have been explicitly suppressed and don't affect scanner status
    • Critical (C): Highest severity findings that require immediate attention
    • High (H): Serious findings that should be addressed soon
    • Medium (M): Moderate risk findings
    • Low (L): Lower risk findings
    • Info (I): Informational findings with minimal risk
  • Duration (Time): Time taken by the scanner to complete its execution
  • Actionable: Number of findings at or above the threshold severity level that require attention
  • Result:
    • PASSED = No findings at or above threshold
    • FAILED = Findings at or above threshold
    • MISSING = Required dependencies not available
    • SKIPPED = Scanner explicitly disabled
    • ERROR = Scanner execution error
  • Threshold: The minimum severity level that will cause a scanner to fail
    • Thresholds: ALL, LOW, MEDIUM, HIGH, CRITICAL
    • Source: Values in parentheses indicate where the threshold is set:
      • global (global_settings section in the ASH_CONFIG used)
      • config (scanner config section in the ASH_CONFIG used)
      • scanner (default configuration in the plugin, if explicitly set)
  • Statistics calculation:
    • All statistics are calculated from the final aggregated SARIF report
    • Suppressed findings are counted separately and do not contribute to actionable findings
    • Scanner status is determined by comparing actionable findings to the threshold
Scanner Suppressed Critical High Medium Low Info Actionable Result Threshold
bandit 0 3 0 0 5948 0 3 FAILED MEDIUM (global)
cdk-nag 0 0 0 0 0 0 0 PASSED MEDIUM (global)
cfn-nag 0 0 0 0 0 0 0 MISSING MEDIUM (global)
checkov 0 0 0 0 0 0 0 PASSED MEDIUM (global)
detect-secrets 0 1 0 0 0 0 1 SKIPPED MEDIUM (global)
grype 0 0 0 0 0 0 0 MISSING MEDIUM (global)
npm-audit 0 0 0 0 0 0 0 PASSED MEDIUM (global)
opengrep 0 0 0 0 0 0 0 MISSING MEDIUM (global)
semgrep 3 0 0 0 0 0 0 PASSED MEDIUM (global)
syft 0 0 0 0 0 0 0 MISSING MEDIUM (global)

Top 2 Hotspots

Files with the highest number of security findings:

Finding Count File Location
2 tests/comparators/test_anls_leaf_semantics.py
2 tests/structured_object_evaluator/test_rollup_node_semantics.py

Detailed Findings

Show 4 actionable findings

Finding 1: SECRET-HEX-HIGH-ENTROPY-STRING

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-HEX-HIGH-ENTROPY-STRING
  • Location: tests/comparators/test_anls_leaf_semantics.py:89

Description:
Secret of type 'Hex High Entropy String' detected in file 'tests/comparators/test_anls_leaf_semantics.py' at line 89

Code Snippet:

Secret of type Hex High Entropy String detected

Finding 2: B108

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B108
  • Location: tests/comparators/test_anls_leaf_semantics.py:210-212

Description:
Probable insecure usage of temp file/directory.

Code Snippet:

uuid.UUID(int=1),
            pathlib.Path("/tmp/x"),
            b"bytes",

Finding 3: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1362-1368

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

def published_label(node: dict, section: str, object_lists: set) -> str:
            counts_objects = eval(  # noqa: S307
                cond.group(1),
                {},
                {"data": node, "section": section, "OBJECT_LISTS": object_lists},
            )
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Finding 4: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1367-1369

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

)
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Report generated by Automated Security Helper (ASH) at 2026-10-19T21:58:07+00:00

@sromoam sromoam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work @digalaviz. The three-state rule (None means not collected, [] means none produced) is the right fix. For a default compare_with() dict and for a bulk run with document_non_matches=False, the report now says that no records were collected instead of calling the document clean. Approving, with three small things before merge:

  1. It conflicts with dev and needs a rebase.

  2. tests/reporting/html/README.md:38 uses em dashes. Colons work there.

  3. Please narrow the CHANGELOG entry (CHANGELOG.md:136) to the paths this fixes. Two producers still empty the list before it reaches DataExtractor, so they still render "No non-matches found." over a failing field:

    • aggregate_from_comparisons(): update_from_comparison_result (bulk_structured_model_evaluator.py:288) treats a missing non_matches key as [].
    • A bulk run where every document raised: non_matches == [] and errors is populated.

    The evaluator_format=True dict is #413, which #420 fixes. I'll file the other two as a follow-up rather than grow this PR.

Optional: the None-state note (section_generator.py:103) could mention passing the EvalResult itself, as the terminal printer's message does since #404. Someone who called stickler.evaluate() never calls compare_with().

@sromoam

sromoam commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@digalaviz pls resolve this changelog merge conflict and then we can bring this in.

Resolve the CHANGELOG conflict with the #298 entry, keeping both. Scope the
#411 entry to the paths it fixes, linking #425 and #413 for the rest, and
replace the em dashes in tests/reporting/html/README.md.
@sromoam
sromoam merged commit ace4572 into dev Oct 19, 2026
12 checks passed
@sromoam
sromoam deleted the fix/411-html-false-success branch October 19, 2026 22:01
sromoam added a commit that referenced this pull request Oct 20, 2026
Reconciles #413 with #412 (#411). #412 made DataExtractor.extract_non_matches
return None when no records were collected, and the HTML non-match section
renders the "records missing" note for None. That covers what
has_non_match_records did here, so the helper and its section_generator
branch are dropped and those files match dev. With non_matches now absent
from an evaluator_format=True dict unless requested, the extractor returns
None for it and the report shows the note, not "No non-matches found.".

The evaluator-format HTML tests move to test_html_non_match_records.py,
which drives the renderer without mocks; the bulk case was already there.

CHANGELOG: the #298 and #411 entries no longer list evaluator_format=True
as uncovered (the #425 gap stays), and the #413 entry says it closes it.
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.

[BUG]: the HTML report claims no non-matches for a document with a failing field

2 participants