Skip to content

fix(apiv2): name the reason when a validation failure has one field error - #3992

Merged
Quick104 merged 3 commits into
mainfrom
fix/issue-3991-validation-detail
Nov 11, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/issue-3991-validation-detail

Conversation

@Quick104

@Quick104 Quick104 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #3991
Related issue: #3990 (closed as a duplicate; its form requirements are carried on #3991)
Validation tasks: none

Creating an account on the web sign-up page with a 7-character password, or with a wrong invite code, shows only "The request did not pass validation; see errors." The page never says which field was refused or why.

The server sends the reason, but only in the problem's errors array. Its top-level detail is a fixed summary for every validation failure built only from field errors, and English clients show detail. Any English client that follows the contract shows the same summary on any form that fails this way.

Approach

When a validation_failed problem carries that fixed summary and exactly one field error, the server now sends the field error's detail as the problem's detail. This happens where problems are rendered, so it covers Huma's schema failures and the hand-built problems alike. With several field errors, detail stays the summary. errors is unchanged, and so is translation, which keys on type and field code. The contract's Problem Details section states the rule, and the API docs' single-error examples match it.

The web sign-up form now validates field by field. Create account stays disabled until every field is valid: a username, a valid email, a password of 8 characters to 72 bytes (the rule newPasswordProblem already applies on the password-reset pages), a matching confirmation, and an invite code. Each rule shows under its field once the user has typed in or left it, never on a freshly loaded form, using existing translated strings. When the server still refuses the request, as with a wrong invite code, each field error shows under the field its location names; a toast is left only for errors no field takes. The fields are locked while the request is out, so a refusal can't land on a value typed since. The setup wizard's account step runs the same password length check before sending.

The request editors' error box printed the problem message and any field errors it couldn't place beside a field. Now that the message can equal a field error, the box skips the message when it already shows the same text.

Sign-up is web-only. The Android sign-up screen already checks the length first, and the Apple apps have no sign-up screen. No Apple or Android source compares against the summary text; Apple's request screens map validation_failed by type. jellycompat is unaffected: it doesn't use v2 problems and keeps its own error responses.

Validation

  • Reproduced on a dev deployment built from main (ab8258fe): both the 7-character password and the wrong invite code showed only the summary toast. On a build of e608fcdb, a fresh form shows no rules and a disabled button; a 7-character password shows its rule under the field and nothing is sent, Enter included; a mismatch shows under the confirm field; a wrong invite code shows "Invalid invite code" under that field. With every field valid, the account is created and the browser opens Home. Checked at iPad and phone widths.
  • API on the fix build: a single field error is now the detail; a request with two field errors keeps the summary.
  • TestContractFixtures compares the router's output byte for byte with the committed fixtures. The 140 regenerated fixtures fail against the unfixed code (140 stale) and pass on the fix. go test ./internal/apiv2/ and the fixture schema check pass.
  • A new sign-up page test covers the five acceptance cases on [bug] Sign-up hides why a password or invite code was refused #3991. Run against the head before the form change, 8 of its 9 tests fail; the ninth, a valid sign-up, passes on both.
  • make lint-changed: no issues. Web prettier, eslint and tsc are clean, and the vitest suites for src/pages, src/lib and src/api/v2 pass under Node 24.
  • Validation tasks, read from their issues (the project board itself was not readable): the passed cases in reach are User management / access groups / invites — Server #1196 C1–C2 and User management / access groups / invites — Web admin #1197 C1–C2 (user management, groups, invitations). They use the invitation flow and admin account creation, which this PR does not change beyond more specific single-field error text. The request cases (Requests — Server #1202–Requests — Web #1204) have not been run. Invite-code sign-up and the setup wizard have no validation task.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/issue-3991/

Risks

The detail text of single-field validation failures changes on every /api/v2 route. The contract says clients never parse detail. A client that shows detail in a banner and the field error beside its field will now show the same sentence twice. The web's request editors were the only such place found, and this PR handles them. The 140 contract fixtures change by one line each. The copies vendored in silo-apple and silo-android are pinned snapshots, so they keep the old text until their next refresh.

For a Huma schema failure, the promoted text is Huma's own message, such as "expected length >= 8". That names the limit but not the field. The web avoids it for passwords by checking first.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code, T3 preview browser, a disposable test deployment, Codex (plan review)
  • Model(s): claude-opus-5-5 (implementation, plan cut, code review), gpt-6.1-sol (plan attack)
  • Involvement: AI-assisted
  • Adversarial review: Plan round before implementation. gpt-6.1-sol attacked the plan: it made fixture regeneration mandatory, found the request editors' duplicate message, and dropped an unneeded dedupe in the libraries hook. claude-opus-5-5 cut it down: it dropped a rewrite of Huma's length messages and a standalone Go test, since the regenerated fixtures pin the behavior. A simplify pass changed nothing. A high-level multi-agent code review (claude-opus-5-5 and claude-sonnet finders) found that the editors' dedupe could hide the only error when the field it matched has no control on screen; it now dedupes only against text in the same box. It also found the contract sentence overstated the rule, which is now reworded. The background adversarial review (gpt-6.1-sol, reviewed b921939) found that sign-up did not yet meet the form requirements carried on [bug] Sign-up hides why a password or invite code was refused #3991 (disabled button, errors under fields, server errors placed by field); the sign-up form commit implements them, with a simplify pass that derived the field type from its list.

🤖 Generated with Claude Code

…rror

A validation failure set its detail to "The request did not pass
validation; see errors." and put the reason only in errors[]. English
clients show the detail, so web sign-up answered a short password or a
wrong invite code with that sentence alone.

The problem renderer now copies the sole field error's detail into the
detail. Several field errors keep the summary. Sign-up and the setup
wizard check the password length before sending, and the request editors
don't print a message twice in their error box.

Closes #3991

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 11, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T20:48:38.269642Z 13e0491 New commits
🔒 Security Review ✅ Completed 2026-11-11T20:51:35.138301Z 13e0491 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The API promotes a sole nonempty field-error detail into the validation problem summary. Fixtures and documentation show specific validation details. Signup and setup forms validate passwords, and signup displays client and server field errors. Admin request editors suppress duplicate error summaries.

Changes: Validation detail handling

Layer / File(s) Summary
API problem detail selection
internal/apiv2/problem.go
Both problem-writing paths use a shared validation summary and promote a sole nonempty field-error detail to the top-level detail.
Validation fixtures and documentation
contracts/api/v2/fixtures/*, docs/architecture/api-contract.md, docs/downloads-api.md, docs/settings-api.md
Fixtures and examples show specific validation details. The API contract documentation describes when the problem detail uses the single field error’s detail.
Signup and setup password validation
web/src/lib/newPassword.ts, web/src/pages/Signup.tsx, web/src/pages/Signup.test.tsx, web/src/pages/setup-wizard/steps/AccountStep.tsx
Signup validates fields, maps server field errors to inputs, and disables submission for invalid values. The setup account step checks password rules before submitting. Tests cover invalid and valid signup cases.
Admin form error display
web/src/pages/admin-settings/RequestRuleEditor.tsx, web/src/pages/admin-settings/RequestServers.tsx
Admin request editors omit a form summary when its text matches an unplaced field error. They continue to display unplaced errors.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

Possibly related PRs

Suggested labels: bug, go, javascript, api-v2

Suggested reviewers: rhainland, blurbery

Merge Risk: Minimal · up to 13e04

The change makes validation messages more specific for API responses and the web sign-up form. No merge-blocking risk is identified in the reviewed evidence.

Security architecture risk: Low · up to 13e04

The inspected changes preserve server-controlled signup and authentication while making validation failures more specific. No introduced security weakness was identified, but downstream use of the changed error text was only partially checked.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The behavior applies through both the Huma transformer and direct problem writer, so exposure is broader than signup alone. An inspected password-refusal fixture changes only the top-level detail to duplicate text already present in its errors array.

Security Findings and Attack Paths

  • inferred — On the inspected paths, the PR makes existing refusal information more visible without adding a credential-disclosure source or expanding signup authority. This conclusion does not establish the safety of every field-error producer or downstream consumer.

Trust Boundaries and Controls

  • observed — Signup validation remains a client-side preflight rather than an authorization decision. It checks invite-code presence, sends the original value to the server, and displays authoritative server refusals. Authentication state continues to derive from the server's returned token pair.

Resilience and Maintainability Implications

  • observed — The observation hook called after promotion records only the problem type identifier, not the more specific detail. The inspected direct writer also retains application/problem+json and no-store response headers.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly identifies the main API v2 change: promoting the sole field error to the validation failure detail.
Linked Issues check Passed Issue #3991 requires the web sign-up page to explain short-password and invalid-invite-code failures. Signup.tsx adds client validation for password length and field-level error rendering. It maps s…
Out of Scope Changes check Passed The API problem change, contract documentation, fixtures, and sign-up tests support issue #3991 by exposing and verifying the specific validation message. The setup-wizard password check applies the s…
Description check Passed The description directly explains the API validation-detail changes, web sign-up validation behavior, related editor updates, tests, risks, and linked issue objectives.
Full details: Linked Issues check

Explanation

Issue #3991 requires the web sign-up page to explain short-password and invalid-invite-code failures. Signup.tsx adds client validation for password length and field-level error rendering. It maps server body.* errors to the related fields, including invite-code errors. Signup.test.tsx covers initial state, password limits, invite-code errors, blocked invalid submissions, pending locking, and successful signup. newPasswordLengthProblem also covers the setup wizard account step. The API promotes a sole field error to detail, which supplies the field message used by the web client.

Full details: Out of Scope Changes check

Explanation

The API problem change, contract documentation, fixtures, and sign-up tests support issue #3991 by exposing and verifying the specific validation message. The setup-wizard password check applies the same account password rule. Request-editor deduplication prevents duplicate text caused by the API contract change. The reviewed changes do not demonstrate an unrelated product change.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a01bb24e-034b-41e2-9876-e427bd79ac6c
Commits

Reviewing files that changed from the base of the PR and between e608fcd and 13e0491.

Files selected for processing: 2

  • web/src/pages/Signup.test.tsx
  • web/src/pages/Signup.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review (gpt-6.1-sol, reviewed b921939)

One verified finding below. Focused API validation and contract-fixture tests passed. The v1.0 validation board could not be checked because the available token lacks read:project.

Comment thread web/src/pages/Signup.tsx Resolved
Create account stays disabled until every field is valid: a username,
a valid email, a password of 8 characters to 72 bytes, a matching
confirmation, and an invite code. Each rule shows under its field once
the user has typed in or left it, instead of in a toast. A refusal from
the server, such as a wrong invite code, shows under the field its
location names; the toast is only for errors no field takes.

Refs #3991

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Nov 11, 2026
@silo-kody

silo-kody Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment thread web/src/pages/Signup.tsx Resolved
Comment thread web/src/pages/Signup.tsx Resolved
A refusal for one submission could land under a field the user had
edited since. The fields are now disabled until the request settles.

Refs #3991

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fce3dd79-c824-4a43-8ee6-814943d54031
Commits

Reviewing files that changed from the base of the PR and between b921939 and e608fcd.

Files selected for processing: 3

  • web/src/lib/newPassword.ts
  • web/src/pages/Signup.test.tsx
  • web/src/pages/Signup.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment thread web/src/pages/Signup.tsx Resolved
@coderabbitai coderabbitai Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code javascript Pull requests that update javascript code labels Nov 11, 2026
@Quick104
Quick104 merged commit d7d6d97 into main Nov 11, 2026
7 checks passed
@Quick104
Quick104 deleted the fix/issue-3991-validation-detail branch November 11, 2026 23:57
@coderabbitai coderabbitai Bot mentioned this pull request Nov 24, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code javascript Pull requests that update javascript code size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Sign-up hides why a password or invite code was refused

1 participant