Repository navigation
Conversation
- reverting _get_document_count to its 1.0.1 body brought back "None Documents" in the bulk title with every reporting test green - the bool guard on the executive summary cards had no test either - each new test fails under its mutation and passes on dev
- awslabs#474 changes ReportResult.metadata["document_count"] and the bulk title the same way as the card; the entry only named the card
Security Scan ResultsASH Security Scan Report
Scan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies:
Top 4 HotspotsFiles with the highest number of security findings:
Detailed FindingsShow 7 actionable findingsFinding 1: SECRET-HEX-HIGH-ENTROPY-STRING
Description: Code Snippet: Finding 2: B310
Description: Code Snippet: Finding 3: B108
Description: Code Snippet: Finding 4: B307
Description: Code Snippet: Finding 5: B307
Description: Code Snippet: Finding 6: B102
Description: Code Snippet: Finding 7: B310
Description: Code Snippet: Report generated by Automated Security Helper (ASH) at 2026-11-11T02:33:40+00:00 |
vawsgit
left a comment
There was a problem hiding this comment.
needs changes
Two medium findings and four low ones, each in an inline comment, plus two optional notes. Measured at head be8d82c, with stickler imported from that checkout's src.
The PR's verification claims hold. Reverting _get_document_count to its 1.0.1 body fails both new reporter tests. Removing and not isinstance(value, bool) fails the bool test. The two test files give 61 passed.
To change:
- The test named for
ReportResult.metadatanever callsgenerate_report. With the metadata line back on the 1.0.1 lookup, the full suite gives 4119 passed, 13 skipped, 1 xfailed. (medium) - The bool test mocks the gauge, and the gauge still scores
cm_f1=Trueas a green 100%. (medium) - No test pins a zero count, or a dict whose
document_countisNone. (low) - The #467 CHANGELOG entry still omits that integer scores now show as
1.000in a threshold colour, which the #474 review raised. (low) - The new CHANGELOG clause does not state the new metadata values. (low)
- The dict test's docstring says the title uses a dict's count. It never does. (low)
Optional: an issue reference in the bool test's docstring, and a title assertion that does not pin the 1 Documents plural.
Each suggested test was run against head and against each mutation named in its comment, and ruff check is clean on them.
| results = ProcessEvaluation(metrics={}) | ||
|
|
||
| assert self.reporter._generate_title(results, True) == "Evaluation Report - 1 Documents" | ||
| assert self.reporter._get_document_count(results) == 1 |
There was a problem hiding this comment.
This test is named for ReportResult.metadata, but it never calls generate_report. Neither new reporter test does: both call the private helpers only. So generate_report's metadata line and its page-title call can go back to the 1.0.1 lookup with every test passing.
Measured at be8d82c, with stickler imported from that checkout's src:
- Line 117 as
getattr(evaluation_results, "document_count", 1):generate_report(ProcessEvaluation(metrics={}), path).metadata["document_count"]isNone, and a dict withdocument_count: 7reports1. The full suite gives 4119 passed, 13 skipped, 1 xfailed. - Line 175 building the title inline with the 1.0.1 lookup: the written page's
<title>isEvaluation Report - None Documents.tests/reportinggives 171 passed.
The existing metadata asserts cannot tell either change apart. They use a dict without the key (line 63) or a Mock with a set count (line 87, and test_output_validation.py:217).
The test below goes through generate_report. It passes at head. It fails under the _get_document_count revert from the PR body, under the line-117 change, and under the line-175 change.
| assert self.reporter._get_document_count(results) == 1 | |
| assert self.reporter._get_document_count(results) == 1 | |
| def test_generate_report_never_shows_none_document_count(self): | |
| """generate_report's metadata and page title use the count, not None (#467).""" | |
| for results, expected in ( | |
| (ProcessEvaluation(metrics={}), 1), | |
| ({'overall': {}, 'document_count': 7}, 7), | |
| ): | |
| report = self.reporter.generate_report(results, self.output_path) | |
| with open(self.output_path, encoding='utf-8') as f: | |
| page = f.read() | |
| assert report.success, report.errors | |
| assert report.metadata["document_count"] == expected | |
| assert 'None Documents' not in page |
|
|
||
| def test_executive_summary_does_not_score_a_bool_metric(self): | ||
| """bool is an int subclass, so True must not render as a coloured 1.000.""" | ||
| generator = SectionGenerator({'overall': {'cm_f1': True}}, self.mock_viz_engine) |
There was a problem hiding this comment.
This test passes while the same Executive Summary still scores cm_f1=True. The gauge guard has no bool check, so a real report draws a green 100% Overall gauge above the uncoloured True card.
stickler/src/stickler/reporting/html/section_generator.py
Lines 26 to 28 in be8d82c
The test cannot see the gauge. self.mock_viz_engine is a Mock(spec=VisualizationEngine): it receives generate_performance_gauge(True, config) and writes a Mock repr into the page. '1.000' not in result would pass even with the real engine, because the gauge prints 100%. Measured at be8d82c with a real VisualizationEngine: the gauge is conic-gradient(#28a745 100%, ...) labelled 100%, and both assertions still pass.
The field views break this docstring's rule word for word. A field with cm_f1: True renders as a green 1.000 bar in generate_field_performance_chart and a green 1.000 cell in generate_field_performance_table. The comment at section_generator.py:43-46 says the cards treat scores "consistently with the gauge and field views". For a bool, they do not.
tests/reporting/html/README.md covers this case: "when the question is what the renderer decides about real results, build the results for real."
Fix, one of:
- Add
and not isinstance(f1_score, bool)tosection_generator.py:27, and assertself.mock_viz_engine.generate_performance_gauge.assert_not_called()in this test. With that check added,tests/reportingstill gives 171 passed. - Keep the PR test-only: rename the test and its docstring so they claim the card only, and file the gauge and field views separately.
|
|
||
| def test_get_document_count_reads_a_results_dict_key(self): | ||
| """The title and ReportResult.metadata use a dict's document_count (#467).""" | ||
| assert self.reporter._get_document_count({'overall': {}, 'document_count': 7}) == 7 |
There was a problem hiding this comment.
The new tests pin the count fallback for two inputs only: a ProcessEvaluation with no count, and a dict with 7. Two plausible rewrites of DataExtractor.get_document_count pass all 171 tests in tests/reporting (measured at be8d82c):
stickler/src/stickler/reporting/html/utils/data_extractors.py
Lines 99 to 105 in be8d82c
return 1 if count is None else countrewritten asreturn count or 1. A zero-document run, such asaggregate_from_comparisons([])withdocument_count=0, then reportsEvaluation Report - 1 Documentsand metadata1. Head reports0, as 1.0.1 did.- The dict branch rewritten as
return results.get('document_count', 1). A dict with an explicitdocument_count: None, such asProcessEvaluation(metrics={}).model_dump(), then rendersNoneon the Documents card and in the metadata. That is HTML report Executive Summary: metric cards are never coloured, and the Documents count is wrong for a dict or a missing count #467's "never rendersNone" case, for a dict.
The test below passes at head and fails under each rewrite:
| assert self.reporter._get_document_count({'overall': {}, 'document_count': 7}) == 7 | |
| assert self.reporter._get_document_count({'overall': {}, 'document_count': 7}) == 7 | |
| def test_get_document_count_keeps_zero_and_replaces_a_dict_none(self): | |
| """A count of 0 stays 0, and a dict's explicit None counts as 1 (#467).""" | |
| assert self.reporter._get_document_count(ProcessEvaluation(document_count=0, metrics={})) == 0 | |
| assert self.reporter._get_document_count({'overall': {}, 'document_count': None}) == 1 |
| the right document count.** A guard on a method that does not exist kept every | ||
| card blue regardless of `color_thresholds`, and the Documents card ignored a |
There was a problem hiding this comment.
This entry still leaves out one visible change from #474, which the #474 review raised. Integer scores changed from an uncoloured 1 to 1.000 in a threshold colour. "Kept every card blue" is also wrong for those cards: 1.0.1 showed an integer score as 1 in #010101.
Input {'overall': {'cm_precision': 0.444, 'cm_recall': 1}}:
- 1.0.1: Precision
0.444in#007bff, Recall1in#010101. be8d82c: Precision0.444in#fd7e14, Recall1.000in#28a745.
Anyone who diffs or parses report HTML sees 1 become 1.000, and no entry explains it. RELEASING.md says: "Entries are for changes a user can observe."
Suggested wording for that sentence: "A guard on a method that does not exist kept every float score blue regardless of color_thresholds, and showed an integer score such as 1 uncoloured. Integer scores now show as 1.000 in a threshold colour."
| now read in one place, `DataExtractor.get_document_count`, so the bulk title | ||
| and `ReportResult.metadata["document_count"]` change the same way |
There was a problem hiding this comment.
This clause does not say what the metadata values become, and "the same way" reads as if a dict's count now reaches the title.
ReportResult.metadata["document_count"]for aProcessEvaluationwith no count:Nonein 1.0.1,1now.- The same key for a results dict with
document_count: 7:1in 1.0.1,7now. - A dict's title is
Evaluation Reportin both versions, because a dict is never bulk (html_reporter.py:149).
A caller that read None as "count unknown" now gets 1, and this entry does not tell them. The #474 review asked for these two metadata changes to be named.
| now read in one place, `DataExtractor.get_document_count`, so the bulk title | |
| and `ReportResult.metadata["document_count"]` change the same way | |
| now read in one place, `DataExtractor.get_document_count`. The bulk title and | |
| `ReportResult.metadata["document_count"]` now show `1` instead of `None` for a | |
| `ProcessEvaluation` without a count, and the metadata reports a results dict's | |
| own `document_count` instead of `1` |
| assert self.reporter._get_document_count(results) == 1 | ||
|
|
||
| def test_get_document_count_reads_a_results_dict_key(self): | ||
| """The title and ReportResult.metadata use a dict's document_count (#467).""" |
There was a problem hiding this comment.
The title half of this docstring is false. _generate_html_content sets is_bulk = isinstance(results, ProcessEvaluation) (html_reporter.py:149), so a dict's title is always Evaluation Report and never shows its count. The test also reads neither the title nor the metadata: it calls _get_document_count only.
| """The title and ReportResult.metadata use a dict's document_count (#467).""" | |
| """_get_document_count reads a results dict's document_count key (#467).""" |
| assert 'None' not in result | ||
|
|
||
| def test_executive_summary_does_not_score_a_bool_metric(self): | ||
| """bool is an int subclass, so True must not render as a coloured 1.000.""" |
There was a problem hiding this comment.
Optional: this regression test's docstring has no issue reference. The bool check came from #474, for #467, and the PR's two other new tests end with (#467). docs/docs/Getting-Started/Contributing/testing-guide.md:287 asks for one: "Documentation: Include issue reference in docstring".
| """bool is an int subclass, so True must not render as a coloured 1.000.""" | |
| """bool is an int subclass, so True must not render as a coloured 1.000 (#467).""" |
| """A ProcessEvaluation without document_count counts as 1, not None (#467).""" | ||
| results = ProcessEvaluation(metrics={}) | ||
|
|
||
| assert self.reporter._generate_title(results, True) == "Evaluation Report - 1 Documents" |
There was a problem hiding this comment.
Optional: the exact match also pins the 1 Documents plural, which the PR body leaves out of scope. A later fix to 1 Document would then have to edit this #467 test. This check still fails on None Documents and accepts either plural:
| assert self.reporter._generate_title(results, True) == "Evaluation Report - 1 Documents" | |
| assert "- 1 Document" in self.reporter._generate_title(results, True) |
sromoam
left a comment
There was a problem hiding this comment.
I agree with vawsgit's review. Items 1 and 2 still reproduce on this head (measured against this branch), and those are the ones I'd want fixed before merging. Two small, optional additions:
Smaller
- When you add the zero and dict-
Nonecases from vawsgit's item 3, consider putting them intest_data_extractors.pynext to:243-249, whereget_document_countis already pinned for the dict key and theNonefallback. Please keep the two new reporter tests, or theirgenerate_reportversion from item 1: they're the only tests that fail if_get_document_count(html_reporter.py:316-318) goes back to its 1.0.1 body. test_section_generator.py:127hard-codes the neutral hex, so restyling#010101atsection_generator.py:52fails the test with no change in behaviour. Taking the colour fromColorUtils, as the sibling test at:98does, keeps the "not coloured" check without the hex (inline below).
| results = ProcessEvaluation(metrics={}) | ||
|
|
||
| assert self.reporter._generate_title(results, True) == "Evaluation Report - 1 Documents" | ||
| assert self.reporter._get_document_count(results) == 1 |
There was a problem hiding this comment.
A small one, alongside vawsgit's item 3: the zero and dict-None cases would sit best in test_data_extractors.py next to :243-249, where DataExtractor.get_document_count is already pinned. Nothing pins them today. return count or 1 at data_extractors.py:105, or .get('document_count', 1) in the dict branch, still passes all of tests/reporting (measured against this branch). Please keep this assert, or its generate_report(...).metadata version from item 1: it's one of the only two tests that fail if _get_document_count goes back to its 1.0.1 body.
| generator = SectionGenerator({'overall': {'cm_f1': True}}, self.mock_viz_engine) | ||
|
|
||
| result = generator.generate_executive_summary(ReportConfig()) | ||
|
|
||
| assert 'style="color: #010101;">True' in result |
There was a problem hiding this comment.
Optional: line 127 hard-codes #010101, so a restyle at section_generator.py:52 fails this test with no change in behaviour. '>True</div>' on its own would let a green True card pass, so here is a version that keeps the "not coloured" check without the hex, in the style of the sibling test at :98. It passes at head and still fails with the bool guard removed or with the bool coloured by threshold (measured against this branch):
| generator = SectionGenerator({'overall': {'cm_f1': True}}, self.mock_viz_engine) | |
| result = generator.generate_executive_summary(ReportConfig()) | |
| assert 'style="color: #010101;">True' in result | |
| from stickler.reporting.html.utils import ColorUtils | |
| generator = SectionGenerator({'overall': {'cm_f1': True}}, self.mock_viz_engine) | |
| config = ReportConfig() | |
| result = generator.generate_executive_summary(config) | |
| excellent = ColorUtils.get_performance_color(1, config.color_thresholds) | |
| assert '>True</div>' in result | |
| assert f'color: {excellent};">True' not in result |
tl;dr for humans
Follow-up to #474, as noted in its review. #474 fixed the bulk report title and the bool guard on the Executive Summary cards, but no test failed if either fix was reverted. This adds three tests that fail under those reverts, and one CHANGELOG clause for the
ReportResult.metadatachange. No library code changes.for agents
None" and "both have tests" hold.tests/reporting/html/test_html_reporter.py:test_bulk_title_and_metadata_never_show_none_document_count,test_get_document_count_reads_a_results_dict_key. The existingtest_generate_title_bulk_resultspatches_get_document_count, so it could not catch a revert.tests/reporting/html/test_section_generator.py:test_executive_summary_does_not_score_a_bool_metric.CHANGELOG.md: the HTML report Executive Summary: metric cards are never coloured, and the Documents count is wrong for a dict or a missing count #467 entry now names the bulk title andReportResult.metadata["document_count"].test(report): pin the document count in the bulk title and bool cards(test, no release impact)docs(changelog): note the bulk title and report metadata count change(docs, no release impact)uv run pytest tests/reporting/html/test_html_reporter.py tests/reporting/html/test_section_generator.py: 61 passed.EvaluationHTMLReporter._get_document_countreverted to its 1.0.1 body: the two reporter tests fail.and not isinstance(value, bool)removed fromsection_generator.py: the bool test fails.uv run pytest: 4119 passed, 13 skipped, 1 xfailed.ruff checkon both test files: clean.1 Documentsis unchanged on purpose (pre-existing, out of scope).