#110172CSP backend module: JS error "uuids is not iterable" when applying a mutation suggestion that already has a resolution
Description
In the CSP backend module (Content Security Policy reports), clicking the “Apply” button on a mutation suggestion can throw an unhandled JavaScript error:
Uncaught (in promise) TypeError: s.uuids is not iterable (cannot read property undefined)
Root cause:
CspAjaxController::mutateReportAction() contains an early return that responds with an empty JSON body when a resolution with the same summary already exists, or when the initiating reports cannot be found anymore:
// typo3/sysext/backend/Classes/Security/ContentSecurityPolicy/CspAjaxController.php
$resolution = $this->resolutionRepository->findBySummary($summary);
$reports = $this->reportRepository->findBySummary(...$initiators);
if ($resolution !== null || $reports === []) {
return new JsonResponse(); // <-- no "uuids" key
}
// ...
return new JsonResponse(['initiators' => $initiators, 'uuids' => $reportUuids]);
The client side does not guard against this case and spreads the missing property unconditionally:
// typo3/sysext/backend/Resources/Public/JavaScript/security/element/csp-reports.js
invokeMutateReportAction(report, suggestion) {
// ...
.then(response => response.resolve('application/json'))
.then(data => this.filterReports(...data.uuids)); // <-- data.uuids is undefined
}
Reproduce:
- Enable CSP handling for a site so that violation reports are collected.
- In the CSP backend module, select a report and apply a mutation suggestion (e.g. AssetHandler@wildcardHost for an external domain) – this creates a row in sys_csp_resolution.
- Trigger/keep further reports with the same summary (or simply keep the stale report rows in the list) and click “Apply” on the same suggestion again.
- The AJAX endpoint returns
[](empty JsonResponse), and the module throwsTypeError: s.uuids is not iterablein the browser console.
Observed:
- Unhandled promise rejection in the browser console.
- The report list is not updated; there is no user feedback whatsoever, so it looks like applying the exception silently failed – even though the resolution already exists and is active.
Expected:
- No JS error. The client should tolerate a response without “uuids” (e.g.
data.uuids ?? []), and/or the controller should always return a consistent shape (['uuids' => []]). - Ideally the user gets a notification for this case, e.g. “This mutation has already been applied”, since the current behavior gives no feedback at all.
Suggested fix:
Either (or both):
csp-reports.js:this.filterReports(...(data.uuids ?? []))– same guard for the muteReport and deleteReport handlers, which share the pattern.CspAjaxController::mutateReportAction():return new JsonResponse(['uuids' => []])instead of an empty response, so the contract of the endpoint stays stable.
Additional note:
handleReportAction() has a similar edge case: when the report is not found it returns an empty JsonResponse, which is then assigned to this.suggestions and would break this.suggestions.map(...) during rendering.
Reviews 1
History 01
-
Gerrit Code Review pushed patch set 1 for main to change 96075 status
NewUnder Review <span data-processor="relativetime" data-value="2026-09-25T13:18:01+00:00" > 09/25/26, 13:18 </span>