Skip to content

Show the library's message when a sign-in is refused (PP-5235) - #334

Draft
dbernstein wants to merge 1 commit into
mainfrom
claude/android-auth-show-title-c1f20b
Draft

dbernstein wants to merge 1 commit into
mainfrom
claude/android-auth-show-title-c1f20b

Conversation

@dbernstein

@dbernstein dbernstein commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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_title option 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:

Server error: 403 Forbidden

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 title as framing above it, or without that framing when the library has turned it off.

  • New AccountAuthenticatedHTTP.problemReportMessage(problemReport, fallback), alongside the existing handle401Error. It returns detail alone when showTitle is false, title + blank line + detail otherwise, and fallback whenever the server gave us nothing worth showing.
  • Wired into the two places that turn an HTTP error into a login failure message: PatronUserProfiles.onPatronProfileRequestHTTPError and ProfileAccountLoginTask.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: false on 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_title on 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's detail, 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 usable detail still reads exactly as it does today.

Two things deliberately not touched:

  • The HTTP_UNAUTHORIZED branches 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 in AccountDetailFragment and 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 in errorCode (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:

Case Expected
show_title: false with title and detail detail alone — the ticket's case
no show_title member title + detail (pre-extension behaviour)
show_title: true title + detail
no problem report caller's fallback
report with detail = null caller's fallback
report with blank detail caller's fallback
detail present, title = null detail alone
detail present, blank title detail alone

The 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 over show_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.

⚠️ Not compiled or run locally. There is no Android SDK on the machine this was written on, so neither the Kotlin compiler nor palace-tests nor 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 three src/main files 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_title contract 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant