fluxer-api: is_sudo_verification_failure should decide by field path, not code #724

Open
opened 2026-11-15 23:04:48 +00:00 by charles · 0 comments
Owner

Deferred from the review of PR #719 (Task 4, #670).

ApiError::is_sudo_verification_failure() (crates/fluxer-api/src/error.rs) is true only when the code that classify lifts out of a 400 INVALID_FORM_BODY is one of the three SUDO_VERIFICATION_CODES (INVALID_PASSWORD, INVALID_MFA_CODE, PASSWORD_NOT_SET). The original (fluxer_app/src/features/platform/transport/RestTransport.ts isSudoVerificationFailure) re-prompts on any 400 INVALID_FORM_BODY with an errors[] entry whose path (or field) is one of the five SUDO_VERIFICATION_ERROR_FIELDS, whatever its code. So a schema error (e.g. a length code) or an entry without a code on password, mfa_code or mfa_method fails the action instead of asking again. fluxer_proto::errors::ApiErrorBody::is_sudo_verification_failure already decides by path.

Why not fixed in #719: ApiError::Http { status, code, message } keeps no field path, so deciding by path needs a new field (or a variant) on ApiError::Http, whose constructors and patterns span fluxer-api, fluxer-devserver tests and apps/fluxer runtimes; that is a cross-crate change outside Task 4's files.

Suggested fix: record at classify time that the refusal named an identity-check field (e.g. Http { .., sudo_field: bool } or a dedicated variant), and have is_sudo_verification_failure() read that. Task 19 (the identity-check dialog) inherits the current behaviour until then.

Steps to reproduce: answer a sudo-capable request (update_guild, delete_guild, transfer_ownership) with 400 {"code":"INVALID_FORM_BODY","errors":[{"path":"password","message":"..."}]} (no code) or with a non-verification code on password: is_sudo_verification_failure() is false.

Seen on branch serveradmin-4-api-community-roles-sudo, commit 1e82ab07.

Deferred from the review of PR #719 (Task 4, #670). `ApiError::is_sudo_verification_failure()` (`crates/fluxer-api/src/error.rs`) is true only when the code that `classify` lifts out of a 400 `INVALID_FORM_BODY` is one of the three `SUDO_VERIFICATION_CODES` (`INVALID_PASSWORD`, `INVALID_MFA_CODE`, `PASSWORD_NOT_SET`). The original (`fluxer_app/src/features/platform/transport/RestTransport.ts` `isSudoVerificationFailure`) re-prompts on any 400 `INVALID_FORM_BODY` with an `errors[]` entry whose `path` (or `field`) is one of the five `SUDO_VERIFICATION_ERROR_FIELDS`, whatever its code. So a schema error (e.g. a length code) or an entry without a code on `password`, `mfa_code` or `mfa_method` fails the action instead of asking again. `fluxer_proto::errors::ApiErrorBody::is_sudo_verification_failure` already decides by path. Why not fixed in #719: `ApiError::Http { status, code, message }` keeps no field path, so deciding by path needs a new field (or a variant) on `ApiError::Http`, whose constructors and patterns span fluxer-api, fluxer-devserver tests and apps/fluxer runtimes; that is a cross-crate change outside Task 4's files. Suggested fix: record at classify time that the refusal named an identity-check field (e.g. `Http { .., sudo_field: bool }` or a dedicated variant), and have `is_sudo_verification_failure()` read that. Task 19 (the identity-check dialog) inherits the current behaviour until then. Steps to reproduce: answer a sudo-capable request (`update_guild`, `delete_guild`, `transfer_ownership`) with 400 `{"code":"INVALID_FORM_BODY","errors":[{"path":"password","message":"..."}]}` (no code) or with a non-verification code on `password`: `is_sudo_verification_failure()` is false. Seen on branch serveradmin-4-api-community-roles-sudo, commit 1e82ab07.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#724
No description provided.