Skip to content

fix(api): name the reason a title allowance is refused - #5885

Merged
Quick104 merged 2 commits into
mainfrom
fix/allowance-problem-codes
Dec 5, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/allowance-problem-codes

Conversation

@Quick104

@Quick104 Quick104 commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: Apple N/A (no client branches on these codes; the 422 status and English detail are unchanged); Android N/A (same); Roku N/A (no title allowance screens); Web N/A (updated here: the four new field-error strings ship with the translation re-pin)

When the household's primary profile tries to allow a limited profile a title or collection and the server refuses, /api/v2 answered a bare 422 validation_failed. The operation descriptions and docs/catalog-api.md promised no_maturity_limits, no_library_access and collection_not_live, but the server never sent them. The allowance service returns each refusal with its code, and the v2 layer dropped it. A client could tell the refusals apart only by parsing the English detail, and a translated interface could only show a generic "didn't pass validation" message.

The v2 allowance routes now keep 422 validation_failed and add one field error that names the reason, at the path parameter it is about:

Code Location When
no_maturity_limits path.id the profile has no rating or advisory-age limit
no_library_access path.item_id the profile can't see the title's library
not_a_title path.item_id, or path.id on listTitleAllowanceProfiles the item is an episode or season
collection_not_live path.collection_id the collection isn't a manual one the primary profile created

Approach

The contract adds a domain problem type only when a client needs distinct corrective behavior, so these use field-error codes, as reordered_series already does. A small allowanceProblem mapper next to the allowance routes turns the service's coded 422s into that shape and passes everything else to serviceProblem unchanged. The location depends on the route, so the mapper sits with the routes and serviceProblem stays as it is for every other handler.

The operation descriptions and docs/catalog-api.md now describe what the server sends. The four error.field.* strings went into the catalog in Silo-Server/silo-translations#229 (merged, with translations), and the web app is re-pinned to its release.

The admin allowance routes in #5873 still call serviceProblem. Once both merge, they can call allowanceProblem, which needs a profile location of path.profile_id there.

Validation

  • A new route test sends an allow request through the real v2 router, with the service returning the handler's no_library_access refusal. It fails on main (errors = []) and passes here.
  • go test ./internal/apiv2/... and ./internal/api/handlers/ pass.
  • make lint-changed reports 0 issues.
  • The OpenAPI artifact, web types and contract diff are current, with no breaking changes.
  • The web typecheck passes after the re-pin.

Nothing visual changes: English clients show the same detail text as before.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-5885/

Risks

A client that matched the old bare 422 still gets a 422 with the same English detail; the body only gains errors[]. None identified beyond that.

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 how I checked a change nobody sees.

Council review

Ran as a follow-up of the review of #5873: one plan reviewer and one background reviewer, both at medium effort.

Rounds: 1, last reviewed 2040d26

Member Round 1
Sol (gpt-6.2-sol, medium) 9/10

Fixed: the collection allowance docs now say only PUT refuses, and DELETE removes an allowance even after the profile's limits are cleared (docs only, so no further round).

Plan check (Opus, claude-opus-5-5, medium): the premises held. Its one cut, a single item-location argument in place of a per-route location struct, was adopted.

AI Disclosure

  • Harness: T3 Code (Claude Code)
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5 (implementation, plan check, code-review finders), claude-sonnet-5-5 (code-review cleanup finder and validation check), gpt-6.2-sol (background review); claude-opus-5-5 translation pass in silo-translations#229
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: a medium-level code review with three finders and a validation check found no defects; two cleanups were adopted (the package's errors.AsType idiom and the existing locationPathID constant). The simplify pass changed nothing. See Council review.

🤖 Generated with Claude Code

Note

Add validation field codes to refused title allowances in API v2

  • Adds allowanceProblem in title_allowances.go to map qualifying 422 errors from the title-allowance services into validation problems with a field code and request location, e.g. path.item_id for no_library_access and not_a_title.
  • Adds constants in problem.go for the new codes: no_maturity_limits, no_library_access, not_a_title, and collection_not_live.
  • Updates API docs in catalog-api.md, the OpenAPI document, the generated web schema, and all locale files with the new field-error messages.
  • Behavioral Change: refusal responses on title PUT, collection PUT, collection copy, and profile lookup now return 422 validation_failed with a field code and location instead of a generic service problem; check allowanceProblem and its callers in internal/apiv2 for the exact mappings.

Macroscope summarized 635b782.

The v2 allowance routes answered every refusal as a bare 422
validation_failed, dropping the service's no_maturity_limits,
no_library_access, not_a_title and collection_not_live codes the operation
descriptions promised. They now carry one field error with that code at the
path parameter it is about, so clients can tell the refusals apart and show
translated text for each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Dec 5, 2026
@silo-kody

silo-kody Bot commented Dec 5, 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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 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-12-05T20:09:07.850814Z 2040d26 PR opened
🔒 Security Review ✅ Completed 2026-12-05T20:14:13.268705Z 635b782 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.

@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.2-sol, reviewed 2040d26)

AI disclosure: Codex (gpt-6.2-sol).

Comment thread docs/catalog-api.md Resolved
@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The API now maps recognized title and collection allowance refusals to field-specific validation problems. API documentation describes the error codes and field paths. New messages for these errors are available in the supported locales.

Changes: Title allowance validation

Layer / File(s) Summary
Validation error mapping
internal/apiv2/problem.go, internal/apiv2/title_allowances.go, internal/apiv2/title_allowances_test.go
Adds four allowance refusal codes and maps recognized 422 service errors to validation problems at the relevant request fields. A test checks the code, field path, and detail for a title allowance refusal.
API validation documentation
internal/apiv2/title_allowances.go, contracts/api/v2/openapi.json, web/src/api/v2/schema.ts, docs/catalog-api.md
Documents validation codes and field paths for title and collection allowance operations, including title types, profile limits, library access, and collection eligibility. The catalog documentation also states that deleting a collection allowance skips the creation checks.
Localized validation messages
.silo-translations, web/src/locales/keys.ts, web/src/locales/*.json
Adds translations for the four validation errors across the locales and adds their keys to MessageKey. Updates the translation manifest version and hash.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant TitleAllowanceHandler
  participant AllowanceService
  participant allowanceProblem
  Client->>TitleAllowanceHandler: Submit title allowance request
  TitleAllowanceHandler->>AllowanceService: Call allowance service
  AllowanceService-->>TitleAllowanceHandler: Return service error
  TitleAllowanceHandler->>allowanceProblem: Map recognized 422 error
  allowanceProblem-->>Client: Return field validation problem
Loading
Merge Risk: Minimal · up to 635b7

Recognized title and collection allowance refusals now return a field-level validation error and keep the existing English top-level detail. No actionable merge-blocking risk remains.

Architecture risk: Low · up to 635b7

Allowance API clients can associate recognized 422 refusal codes with specific request fields, while unmatched refusals continue to use the generic response.

When an allowance service refusal returns one of the recognized 422 codes, the API now provides clients with that code and message at a field-specific location; unmatched codes retain the generic fallback.

Changed areas: web, internal, contracts, docs

Review details

Systems and components

  • observed — 43 changed files mapped to web.
  • observed — 3 changed files mapped to internal.
  • observed — contracts (api) was modified; 1 changed file maps to changed impact.
  • observed — 1 changed file mapped to docs.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(api): name the reason a title allowance is refused" matches the main change. The v2 allowance routes now return a field error with a reason code (no_maturity_limits, no_library_access, …
Description check Passed The description explains the problem (bare 422 validation_failed with no reason code), the approach (allowanceProblem mapper, field-error codes and locations table), the docs and translation changes, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(api): name the reason a title allowance is refused" matches the main change. The v2 allowance routes now return a field error with a reason code (no_maturity_limits, no_library_access, not_a_title, collection_not_live) at the relevant path location, instead of a bare 422 validation_failed. The title is specific and scannable, and it does not cover the locale and docs updates, which is acceptable.

Full details: Description check

Explanation

The description explains the problem (bare 422 validation_failed with no reason code), the approach (allowanceProblem mapper, field-error codes and locations table), the docs and translation changes, validation steps, and risks. It is directly related to the changeset.

Finishing Touches

Generate unit tests (beta)

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

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)

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: d478e600-f9a3-41da-857c-d66f3e1dc775
Commits

Reviewing files that changed from the base of the PR and between 97f88b6 and 635b782.

Files selected for processing: 49

  • .silo-translations
  • contracts/api/v2/openapi.json
  • docs/catalog-api.md
  • internal/apiv2/problem.go
  • internal/apiv2/title_allowances.go
  • internal/apiv2/title_allowances_test.go
  • web/src/api/v2/schema.ts
  • web/src/locales/ar-XB.json
  • web/src/locales/ar.json
  • web/src/locales/bg.json
  • web/src/locales/ca.json
  • web/src/locales/cs.json
  • web/src/locales/da.json
  • web/src/locales/de.json
  • web/src/locales/el.json
  • web/src/locales/en-XA.json
  • web/src/locales/en.json
  • web/src/locales/es.json
  • web/src/locales/et.json
  • web/src/locales/fi.json
  • web/src/locales/fr.json
  • web/src/locales/he.json
  • web/src/locales/hi.json
  • web/src/locales/hr.json
  • web/src/locales/hu.json
  • web/src/locales/id.json
  • web/src/locales/it.json
  • web/src/locales/ja.json
  • web/src/locales/keys.ts
  • web/src/locales/ko.json
  • web/src/locales/lt.json
  • web/src/locales/lv.json
  • web/src/locales/ms.json
  • web/src/locales/nb.json
  • web/src/locales/nl.json
  • web/src/locales/pl.json
  • web/src/locales/pt-BR.json
  • web/src/locales/pt-PT.json
  • web/src/locales/ro.json
  • web/src/locales/ru.json
  • web/src/locales/sk.json
  • web/src/locales/sl.json
  • web/src/locales/sv.json
  • web/src/locales/th.json
  • web/src/locales/tr.json
  • web/src/locales/uk.json
  • web/src/locales/vi.json
  • web/src/locales/zh-Hans.json
  • web/src/locales/zh-Hant.json

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Dec 5, 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 ❌
⚠️ 5 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility
  • Make capability responses reflect effective permissions

@Quick104
Quick104 merged commit b6516b8 into main Dec 5, 2026
20 checks passed
@Quick104
Quick104 deleted the fix/allowance-problem-codes branch December 5, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant