Return empty feed instead of 204 from the DiscoJuice feeds endpoint - #1422
Merged
milanmajchrak merged 2 commits intoSep 2, 2026
Merged
Conversation
When no discofeed content is cached — the default, since `shibboleth.discofeed.allowed` is off — `/api/discojuice/feeds` responded with `204 No Content`. The DiscoJuice IdP-discovery widget on the login and register pages loads this endpoint via JSONP and passes the body straight to `jQuery.merge()`. An empty body leaves the callback argument undefined, so the widget throws `TypeError: Cannot read properties of undefined (reading 'length')` on every default deployment. Respond with an empty but valid feed instead: `callback([])` when a callback is given, `[]` otherwise. The JSONP callback then always fires with a well-formed array and the widget no longer crashes; deployments with feeds enabled are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The login and register pages throw an uncaught JS error on load, which fails the Playwright
consoleErrors.spec.tschecks (2 pages × chromium/firefox/webkit = 6 failing tests):Root cause
The DiscoJuice IdP-discovery widget on those pages loads
/server/api/discojuice/feeds?callback=dj_md_1via JSONP and passes the response body straight tojQuery.merge().ClarinDiscoJuiceFeedsControllerreturned204 No Contentwhenever the feed cache was blank:That cache is populated only by
ClarinDiscoJuiceFeedsUpdateScheduler, which downloads feeds only whenshibboleth.discofeed.allowedis true — and that property defaults tofalse. So on a default deployment the endpoint always returns 204, the JSONP script tag executes with no body, thedj_md_1(...)callback never receives its argument, andjQuery.merge(list, undefined)readsundefined.lengthand throws.A 204 fundamentally breaks the JSONP contract: the response body must be executable JS that calls the callback, so an empty body can never be consumed safely.
Fix
When there is no feed content, return an empty but valid feed instead of a 204:
dj_md_1([])[]The callback now always fires with a well-formed (possibly empty) array, so the widget degrades gracefully (no extra IdPs listed) instead of crashing. Deployments that have
shibboleth.discofeed.allowedenabled and real feed content are unaffected — that path is unchanged.The now-unused
HttpServletResponseparameter and its imports were removed along with thesendErrorbranch.Test
Added
getDiscoFeedsWithoutContentReturnsEmptyFeedtoClarinDiscoJuiceFeedsControllerIT, which forces the empty-cache state and asserts200withdj_md_1([])(with callback) and[](without), instead of a 204. The existinggetDiscoFeedstest (populated feed) still covers the normal path.Verification
Reproduced live on
dev-6.pc:8603: the error fires on/repository/loginand/repository/register(both mount the widget) and not on/repository/home(no widget). The failing network call isGET /server/api/discojuice/feeds?callback=dj_md_1 → 204.🤖 Generated with Claude Code