Repository navigation
Show the library's message when a sign-in is refused (PP-5235) - #334
Draft
dbernstein wants to merge 1 commit into
Draft
dbernstein wants to merge 1 commit into
dbernstein wants to merge 1 commit into
Conversation
A patron blocked by a library policy saw "Server error: 403 Forbidden". The problem document carrying the library's own message was parsed and filed into the error report's attributes, but never displayed. Add AccountAuthenticatedHTTP.problemReportMessage, which composes the user-facing message from a problem report: `detail` alone when the server sent `show_title: false`, `title` above `detail` otherwise, and the caller's existing message whenever the server gave us nothing worth showing. Wire it into the two places that turn an HTTP error into a login failure: the patron profile request, which is the path basic authentication blocks arrive on, and the login task's own error handler. Honouring show_title alone would have changed nothing here, because the title it suppresses was never rendered; displaying `detail` is what makes the option mean anything. That also improves every other login failure carrying a problem document. Responses without a usable `detail` read exactly as before. The 401 branches are left alone: they are not the blocked path, and rendering problem reports there is a separate change. Co-Authored-By: Claude Opus 5 <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.
What's this do?
Shows a patron the message their library actually wrote when a sign-in is refused, and honours the manager's
show_titleoption so a library can have that message stand on its own.Today the app discards both halves of the server's problem document on this path. A patron blocked by a library policy sees:
The library's configured message is parsed, logged, and filed into the Error Details attribute table — but never shown. After this change the same patron sees the library's message, with the problem document's
titleas framing above it, or without that framing when the library has turned it off.AccountAuthenticatedHTTP.problemReportMessage(problemReport, fallback), alongside the existinghandle401Error. It returnsdetailalone whenshowTitleis false,title+ blank line +detailotherwise, andfallbackwhenever the server gave us nothing worth showing.PatronUserProfiles.onPatronProfileRequestHTTPErrorandProfileAccountLoginTask.handleProfileAccountLoginError.Why are we doing this? (w/ JIRA link if applicable)
JIRA: PP-5235
The circulation manager can be configured per library to suppress the standard "Blocked by library policy." title on a patron blocking rule message, for libraries whose message redirects the patron elsewhere and where that title is unwanted framing. It signals this with
show_title: falseon the 403 problem document (circulation#3727):{ "type": "http://librarysimplified.org/terms/problem/credentials-blocked-by-policy", "title": "Blocked by library policy.", "status": 403, "detail": "Please sign in at your local library instead.", "show_title": false }The flag is emitted only when the title should be hidden, so its absence means "render as usual". iOS shipped its half in ios-core#1462; the parsing half of this one shipped in android-http#153, released as 2.7.0 and already on the platform version catalog this branch builds against. No submodule bump is needed.
Worth knowing about the scope. Honouring
show_titleon Android is inert on its own, because the title it would suppress was never displayed in the first place. Delivering the ticket's actual outcome therefore means rendering the problem document'sdetail, and that improves every login failure that carries a problem document, not only blocked ones. That is wider than the ticket's wording and deliberate. Anything without a usabledetailstill reads exactly as it does today.Two things deliberately not touched:
HTTP_UNAUTHORIZEDbranches in both files still say "Invalid credentials!" and still ignore the problem report. SIP2 blocking is a 403, so this is not the blocked path. It is the same gap, and would be a reasonable follow-up, but it is out of scope here.currentStepFailed(message = ...)is dual-purpose: it is both the string the patron reads inAccountDetailFragmentand a diagnostic line in the error report. This change makes it user-facing on this path, so "Server error: 403" no longer leads that message. It is preserved inerrorCode(httpError 403 <uri>) and in the problem report attributes, so nothing is lost for support — but the first line support sees is different now.How should this be tested? / Do these changes have associated tests?
Eight new cases in
AccountAuthenticatedHTTPTest, covering the composition rules directly:show_title: falsewith title and detailshow_titlemembershow_title: truedetail = nulldetailtitle = nullThe
detail-absent cases matter more than they look: suppressing a title must never leave a patron staring at an empty dialog, so the fallback has to win overshow_title.End-to-end confirmation needs a library configured with a blocking rule and the title suppressed, against a manager carrying circulation#3727. That has not been done and is worth doing before release.
palace-testsnor ktlint has seen this. CI is the first execution. Please merge on the CI run rather than on my description of it.I did check statically what I could: ktlint's config excludes
*/src/test/**, so the test file follows the existing no-trailing-comma style in that file, while the threesrc/mainfiles use trailing commas and one-argument-per-line wrapping to match the enabled rules; all changed lines are under the 120-character limit; and the changelog XML parses.Dependencies for merging? Releasing to production?
None outstanding. android-http 2.7.0 is released, on Maven Central, and already referenced by the platform catalog commit this branch pins.
Have you updated the changelog?
Yes, appended to the open 1.33.2 release.
Has the application documentation been updated for these changes?
The new function carries KDoc explaining the
show_titlecontract and why the fallback takes precedence. No other docs in this repo cover problem report rendering.Did someone actually run this code to verify it works?
Not yet — see the warning above. No human has run it, and it has not been exercised against a real blocked-patron response.
🤖 Generated with Claude Code