Skip to content

Commit c91b21c

Browse files
luisleo526claude
andcommitted
ci(release): the probe listing bounds its inventory=ERROR row to 240 characters like the detail-error rows (CR-245 F1 measurement, sol P2)
The new stdout listing printed the whole exception text on an `inventory=ERROR` row, while the per-ruleset `detail=ERROR` rows truncate it to 240 characters; a `gh` transport error with 300 characters of stderr was echoed in full. The row now applies the same bound ([:240], still !r-escaped). Four rows assert the exact bounded line (an inventory transport error, a repository transport error, a default-branch rejection with a long repository argument, an invalid summary with a long field) together with the unchanged stderr, exit code 1 and API call list of the verdict; each has a mutation control that removes only the bound and must fail. The verdict functions are untouched and the verdict's own stderr is not bounded. No documentation sentence is changed (none described a length limit). Lane: ci-fu-cr488n (Codex gpt-6.1-sol). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 5a86654 commit c91b21c

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

‎scripts/ci_release_gate.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def _ruleset_inventory_report(api: API, repo: str) -> str:
439439
identities.add(item["id"])
440440
entries.append(item)
441441
except ReleaseGateError as exc:
442-
lines.append(f"inventory=ERROR {str(exc)!r}")
442+
lines.append(f"inventory=ERROR {str(exc)[:240]!r}")
443443
return "\n".join(lines)
444444

445445
for item in entries:

‎scripts/test_ci_release_gate.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,61 @@ def test_inventory_failures_are_reported_before_the_unchanged_reader_refusal(sel
18081808
reads.append((RULESETS_API, True, None))
18091809
self.assertEqual(api.calls, reads * 2)
18101810

1811+
def test_long_inventory_errors_are_escaped_shortened_and_keep_the_refusal(self):
1812+
detail = "gh: Forbidden (HTTP 403)\n" + "x" * 300
1813+
long_repo = "example/" + "r" * 300
1814+
long_repo_api = f"repos/{long_repo}"
1815+
invalid = {"id": 707, "target": "branch", "enforcement": "unknown" + "x" * 300}
1816+
cases = (
1817+
("inventory transport", REPO, RULESETS_API, subprocess.CalledProcessError(
1818+
1, ["gh", "api", RULESETS_API], stderr=detail),
1819+
f"API {RULESETS_API} failed with HTTP 403: {detail}"),
1820+
("repository transport", REPO, REPO_API, subprocess.CalledProcessError(
1821+
1, ["gh", "api", REPO_API], stderr=detail),
1822+
f"API {REPO_API} failed with HTTP 403: {detail}"),
1823+
("default branch", long_repo, long_repo_api,
1824+
json.dumps({"default_branch": "release"}),
1825+
f"API {long_repo_api} must identify main as the default branch"),
1826+
("summary validation", REPO, RULESETS_API,
1827+
http_response(200, json.dumps([invalid])),
1828+
f"API {RULESETS_API} returned invalid ruleset summary: {invalid!r}"),
1829+
)
1830+
for scenario, repo, endpoint, payload, diagnostic in cases:
1831+
with self.subTest(scenario=scenario):
1832+
self.assertGreater(len(diagnostic), 240)
1833+
api = self.api_for()
1834+
api.responses[endpoint] = payload
1835+
expected = (
1836+
1, RULESET_INVENTORY_HEADER + f"inventory=ERROR {diagnostic[:240]!r}\n",
1837+
f"::error::{diagnostic}\n")
1838+
# RED on 5a866543573c: every row prints the entire diagnostic.
1839+
self.assertEqual(self.run_probe(api, repo=repo), expected)
1840+
reads = [(f"repos/{repo}", False, None)]
1841+
if endpoint == RULESETS_API:
1842+
reads.append((RULESETS_API, True, None))
1843+
self.assertEqual(api.calls, reads * 2)
1844+
1845+
# Revert only the bound in the full module and require this
1846+
# same exact-output assertion to catch every input row.
1847+
source = Path(ci_release_gate.__file__).read_text()
1848+
before = ' lines.append(f"inventory=ERROR {str(exc)[:240]!r}")\n'
1849+
after = ' lines.append(f"inventory=ERROR {str(exc)!r}")\n'
1850+
self.assertEqual(source.count(before), 1,
1851+
"mutation must have one source target")
1852+
mutated = source.replace(before, after, 1)
1853+
self.assertNotEqual(mutated, source)
1854+
namespace = {"__name__": "ci_release_inventory_error_bound_mutant"}
1855+
exec(compile(mutated, ci_release_gate.__file__, "exec"), namespace)
1856+
mutant_api = self.api_for()
1857+
mutant_api.responses[endpoint] = payload
1858+
result = self.run_probe(mutant_api, repo=repo, main=namespace["main"])
1859+
self.assertEqual(result, (
1860+
1, RULESET_INVENTORY_HEADER + f"inventory=ERROR {diagnostic!r}\n",
1861+
f"::error::{diagnostic}\n"))
1862+
with self.assertRaises(AssertionError):
1863+
self.assertEqual(result, expected)
1864+
self.assertEqual(mutant_api.calls, reads * 2)
1865+
18111866
def test_detail_transport_error_is_escaped_shortened_and_does_not_hide_next_row(self):
18121867
rows = self.measurement_rows()
18131868
api = self.api_for(rows)

0 commit comments

Comments
 (0)