Problem/Motivation
The LTI 1.3 content selection (deep linking) controllers return `new RedirectResponse('/', 500)`
in their catch blocks. Symfony's `RedirectResponse` constructor requires a 3xx status code and
throws `InvalidArgumentException` ("The HTTP status code is not a redirect (500 given)") for any
non-redirect status. So when these error paths are hit, instead of the intended graceful redirect
the request dies with an uncaught exception / HTTP 500 — the error handler itself fails.
This is the same defect class fixed in #3460258 for `LTIToolProviderV1P3Launch.php` and
`LTIToolProviderContentLaunch.php`, but the following occurrences were not covered there.
Affected locations (3.0.0 / 3.0.x):
- modules/lti_tool_provider_content/src/Controller/LTIToolProviderContentSelect.php:61 (catch Exception)
- modules/lti_tool_provider_content/src/Controller/LTIToolProviderContentReturn.php:140 (catch LtiExceptionInterface)
- modules/lti_tool_provider_content/src/Controller/LTIToolProviderContentReturn.php:144 (catch Exception)
The same pattern also exists on the 2.x branch.
Steps to reproduce
Trigger an error within the deep-linking content selection flow, e.g.:
- Request `/lti/v1p3/content/select` with a missing/expired LTI context in the session (common when
third-party cookies are blocked inside the LMS iframe), or
- Cause the deep-linking response build to fail at `/lti/v1p3/content/return` (e.g. registration or
signing-key resolution failure).
The catch block then constructs `RedirectResponse('/', 500)`, which throws and yields an HTTP 500
instead of redirecting.
Proposed resolution
Mirror the fix from #3460258 — redirect to a valid location with a valid redirect status, e.g.:
use Drupal\Core\Url;
...
$url = Url::fromRoute('system.403')->toString();
return new RedirectResponse($url, 302);
applied to all three spots (the exact destination/status for the deep-linking error case is open to
discussion — 403 vs. a dedicated error/content page).
Remaining tasks
- Patch the three occurrences.
- Agree on the appropriate redirect target/status for the deep-linking error case.
- Manual verification requires a deep-linking-capable LMS. The current maintainers do not use deep
linking and can't test this, so a reporter who uses content selection is needed to confirm the fix.
Comments