Skip to content

The phone's diary shows «Не получилось: HTTP 429» after too many sign-ins, «Дневник не отвечает» when the diary is switched off, and a raw «HTTP 504» on a timeout #153

Closed

Description

@lumenpearson

What is broken.

The app turns a diary failure into a message with DiaryFailure.of, and that function knows only 401, 404, 422, 502 and 503. It never reads the body the server sent. Three answers the server or the platform really gives come out wrong on the phone:

  • 429 from POST /api/v1/diary/login. The server says «Слишком много попыток входа. Попробуйте позже.» and sends Retry-After. The app has no 429 case, so it becomes Unexpected and the screen prints Retrofit's exception message: «Не получилось: HTTP 429 Too Many Requests», or «Не получилось: HTTP 429 » over HTTP/2, where the reason phrase is empty. docs/api.md says the app should "wait out Retry-After, and do not blame the password". The phone does not say to wait or for how long, and never says that there were too many attempts.
  • 503 because DIARY_SECRET is unset. The server says «Дневник на этом сервере выключен.». DiaryDisabled's own docstring says the person should be told that «instead of «попробуйте позже»». The app maps every 503 to Unavailable and shows «Дневник не отвечает. Попробуйте позже.», which is exactly the sentence the server set out to avoid. Waiting or retrying can never change it; only an operator can.
  • 504. A request that outlives maxDuration: 30 is answered 504 by the platform. The server never emits a 504 itself: this is a timeout in front of it, and the Petersburg client allows 20 s of read per upstream call. This is the "the diary is slow, try again" case. The app has no branch for it, so it also falls to Unexpected and shows «Не получилось: HTTP 504 ».

The English build has the same problem with «It did not work: HTTP 429» and «The diary is not answering. Try again later.».

The failure scenario.

  1. Make ten failed diary sign-ins from one address within fifteen minutes, then press «Войти» an eleventh time.
  2. The server answers 429 with detail «Слишком много попыток входа. Попробуйте позже.» and a Retry-After.
  3. DiaryFailure.of has no 429 case and returns Unexpected(429, HttpException).
  4. The «Не удалось войти» dialog reads «Не получилось: HTTP 429 Too Many Requests», or «Не получилось: HTTP 429 » over HTTP/2. It does not say there were too many attempts, and it does not say how long to wait.
  5. On a deployment without DIARY_SECRET, press «Войти» with any credentials. The server answers 503 «Дневник на этом сервере выключен.».
  6. 503 -> Unavailable, so the dialog reads «Дневник не отвечает. Попробуйте позже.». Every later attempt gives the same answer, however long the person waits.
  7. Open a week of the diary while the upstream is slow enough that the function passes 30 s. The platform answers 504, and the card reads «Не получилось: HTTP 504 » under «Повторить» instead of the «Дневник не отвечает» it has a sentence for.

Where.

  • android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/DiaryModels.kt:368-385: ofHttp has no 429 or 504 case, and at :383 it maps every 503 to Unavailable. The doc comment at :324 says "503: the diary is down. Worth retrying, and only that."
  • android/app/src/main/kotlin/com/lumenpearson/lessons/ui/diary/DiaryScreen.kt:318: Unavailable becomes «Дневник не отвечает».
  • android/app/src/main/kotlin/com/lumenpearson/lessons/ui/diary/DiaryScreen.kt:323-326: Unexpected prints reason.message, which is HttpException's "HTTP ".
  • android/app/src/main/kotlin/com/lumenpearson/lessons/ui/diary/DiarySignInScreen.kt:242-245: the sign-in dialog falls through to asText() for everything but a 401.
  • android/app/src/main/res/values/strings_diary.xml:34,39, twinned at values-en/strings_diary.xml:34,39.
  • server/app/api/diary.py:268-275: the 429.
  • server/app/api/diary.py:290-301: the 503 for a switched-off diary.
  • server/app/services/diary.py:55-61: the stated intent not to say «попробуйте позже».
  • docs/api.md:1165: the documented app behaviour for 429.
  • vercel.json:8: maxDuration: 30.
  • android/core/data/src/test/kotlin/com/lumenpearson/lessons/core/data/repository/DiaryFailureTest.kt: pins only 503 -> Unavailable and the generic fallback. No test covers 429 or 504.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions