Repository navigation
fix(catalog): accept true/false strings and reject other values in boolean filters - #3173
Conversation
A catalog query whose watched, in_progress, favorited, in_watchlist, hdr or dolby_vision rule carried a string such as "true" passed validation and then failed in the query builder, so the API answered 500. Validate the value with the other rule values so the request gets a 422 naming the field.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validation, normalization, and query coverage internal/catalog/query_definition.go, internal/catalog/query_builder_rule_fields_test.go |
Boolean rule validation accepts booleans and exact "true" or "false" strings. Normalization converts those strings to booleans. Tests cover malformed values and confirm string inputs produce the same SQL and arguments as boolean inputs for all and any matching. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- Silo-Server/silo-server#2728: Validates and reads saved collection query definitions across collection APIs, including the same boolean-rule validation flow.
- Silo-Server/silo-server#3156: Uses the
watchedrule in section rows and passes viewer identity into catalog query execution. - Silo-Server/silo-server#3005: Changes optimized episode-catalog execution for query definitions with watch-state rules.
Suggested reviewers: quick104
Merge Risk: 
Minimal · up to 36d3e
-
Exact boolean strings remain supported, and no merge-blocking regression was identified.
Security architecture risk: 
Minimal · up to 36d3e
-
The accepted strings are restricted to exactly "true" and "false" and become ordinary booleans before SQL construction. The reviewed paths retain existing query scoping and validation controls. No material security risk introduced or worsened by this change was identified.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The newly executable string forms reach existing catalog predicates over media metadata and profile-specific viewing/list state. Their normalized values express the same two choices already available through native booleans; they do not supply identity, library scope or arbitrary SQL.
Trust Boundaries and Controls
- observed — Personal predicates still require user/profile scope and use scoped query arguments. HDR values are bound parameters, Dolby Vision uses fixed predicates selected by a boolean, and the complete query expression remains parenthesized when combined with outer constraints.
Resilience and Maintainability Implications
- observed — The relevance-search overlay uses a separate in-memory matcher without boolean-field cases or explicit normalization. That divergence already exists in the base revision; the inspected change does not establish a new access-control bypass through it.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The pull request description directly explains the boolean catalog filter validation and normalization changes, including affected fields, tests, compatibility behavior, and user-visible error handling.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The catalog-query API now returns 422 instead of 500 for a non-boolean filter value, which changes the response visible to clients. The before/after table covers that response change, but does not name the surface or identify the build/commit for each capture. Please identify the catalog-query API surface and tie each response to its source commit; the Suggested fix: update the Evidence section with the surface and before/after commits, and remove the Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Quick104
left a comment
There was a problem hiding this comment.
Note
AI-generated review posted by Quick104 using Codex (gpt-6.1-sol, xhigh) in T3 Code, with an independent Claude (claude-opus-5-5, high) review. Evidence comes from source inspection and an executable harness; no live server or device run was performed.
One P2 finding remains at c5aa5cb936031c32d532948d3990da7ec7180167: strict HDR validation rejects the request sent by released Android clients. The inline finding gives the trigger, evidence, and repair. Preserving the existing HDR string form is my recommendation; requiring a newer Android release needs an explicit rollout decision.
|
Fit: 10/10 · Readiness: 9/10 — ready. Reviewed head The fix belongs in the catalog rule validator, and it now keeps released clients working. The HDR finding from the previous round is fixed: the six true/false fields accept a boolean or exactly Verification
Remaining for maintainers: none blocking. One edge case is accepted on purpose: the base accepted other PostgreSQL boolean strings such as Validated features: Silo-Server/silo-android#350 C1 changes as the PR's Clients and docs: no client change is needed. Android main already sends booleans (Silo-Server/silo-android#702), and Apple and web always did. jellycompat shares the saved-definition validation and gets the same behavior. The manual describes neither the error nor the accepted value types, so it needs no issue. Note AI-generated review posted by Quick104. Previous round: Codex ( |
Released Android TV v1.0.0-beta.27 sends the HDR filter, and its watched, in-progress and favorites filters, as the JSON strings "true" and "false". The previous commit answered those with 422. Read exactly those two strings as booleans when the definition is validated and normalized, so the query builder only sees real booleans and saved definitions that hold them keep working. Any other non-boolean value still fails validation.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
At The invalid-string case ( Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Problem
Related issue: #1253
Validation tasks: changes Silo-Server/silo-android#350 C1 (released Android TV's Watch Status filters start working)
A catalog query with a true/false filter whose value is a string, such as
{"field":"watched","op":"is","value":"true"}, answers 500 "An unexpected error occurred". Released Android TV builds send exactly that, so choosing Watched, In progress or Favorites shows a generic error. The rule passes validation and only fails later, in the query builder. Other strings, such as"yes", fail the same way.The six true/false rule fields now accept a real boolean or exactly the strings
"true"and"false", and any other value gets a 422 that names the field.Approach
validateRuleValuecheckswatched,in_progress,favorited,in_watchlist,hdranddolby_visionwith one helper. It accepts a boolean or exactly"true"/"false", and rejects anything else, including"True","1"and" true", as it already does for numbers, dates and decades.QueryDefinition.Normalize()turns the two strings into booleans for those fields. The query builder, the item and episode executors and saved-definition loading all run on normalized definitions, so they only see booleans."true"inside ananygroup, and its Watched, In progress and Favorites filters now return results. Android main already sends booleans (fix(catalog): send boolean filter values as JSON booleans silo-android#702). Saved smart collections that hold the strings keep working. Saved rules with any other value are refused when saved instead of failing when they run.Validation
"true"/"false"×all/anygroups validate and build the same SQL and arguments as the real boolean. It failed before the change, and still fails with only theNormalizestep removed."True","1"," true", numbers and null for each field; its rows failed before the change.go test ./internal/catalog/... ./internal/apiv2/... ./internal/collections/...,make lint-changed: pass."true"returns the same items as the boolean.Evidence
Evidence:
POST /api/v2/catalog/query(native API) on a test audiobook library, as a viewer profile, with onewatched is <value>rule. Before: a server built from the base commite6df1d8ed. After: a server built from this branch's head36d3ed9damerged with the other #1253 fixes. The two servers have separate test databases, so their watched books differ; on each server, compare the string rule with the real boolean.e6df1d8ed)36d3ed9da)"true"(string)500"An unexpected error occurred."200, 1 item: Hours of Static"yes"(string)500"An unexpected error occurred."422"groups[0].rules[0]: watched requires true or false"true(boolean)200, 2 items200, 1 item: Hours of StaticRisks
None identified.
Checklist
AI Disclosure
queryFieldDefsinstead of listing them in the validation switch; declined because the same switch already names its numeric and date fields this way.Note
Fix catalog rule validation to reject non-boolean values for true/false filters
Adds a
booleanRuleFieldsmap coveringwatched,in_progress,favorited,in_watchlist,hdr, anddolby_visionin query_definition.go.validateRuleValuenow accepts only Go booleans and the exact lowercase strings "true"/"false" for these fields, andQueryDefinition.Normalizeconverts accepted values to Go booleans. Other representations such as "1" and "T" are rejected. Tests in query_builder_rule_fields_test.go cover both rejection of malformed values and equivalence of canonical strings to boolean inputs."1","T", nil) now fail definition and catalog overlay validationMacroscope summarized 36d3ed9.