Files
bookhoard/docs/developer/api/collections/update_collection.md
T
John O'Keefe a86bdac87e refactor(collections): retire the legacy rules surface — tree-only storage
The pre-tree rules machinery is deleted: no row ever carried a rules
array or a non-default match mode (verified in the dev DB), the web
never read the envelope keys, and the Android app consumes none of it.
Dead code gets no documentation.

Removed:
- PUT /api/collections/:id/match-mode — endpoint, route, and the
  UpdateCollectionMatchMode query. The tree's root mode owns any|all.
- auto_assign_rules / rule_match_mode from every envelope
  (create/list/detail/update), from the create/update request shapes,
  and from the schema: both columns DROPPED (schema.sql carries
  idempotent DROP COLUMN IF EXISTS heals for existing DBs; sqlc
  regenerated).
- The rules CRUD service layer (AddRule/SetRuleEnabled/RemoveRule +
  validateRule + UpdateCollectionRulesJSON), ParseRules /
  EnabledRules / IsSmartCollection, RulesToFilterTree (+ the SSR
  preload branch), the legacy branch of EvaluateSmartMembership, and
  SmartEvalOptions.MatchMode. IsCollectionSmart = tree presence;
  create-path isSmart = collection_type=smart OR a filter_tree.

Kept (live consumers): POST /api/collections/preview still evaluates
rules payloads in memory (the custom-section builder's preview), and
include_auto stays on the list (the Android app sends it).

The custom-section builder's SAVE was already broken — its
stringified auto_assign_rules payload failed request binding (probed
live: 400 invalid request). Create now rejects that payload loudly
with a 400 naming the retirement, instead of silently creating a
hollow static section; custom-section-builder.md carries the flag.
The builder's tree migration remains the flagged follow-up.

Test-side (asymmetry rule — deleted behavior, deleted tests):
TestPodcastSmartCollections rewritten onto trees (mode lives in the
tree root), match-mode subtests and tree_wins_over_legacy_rules
deleted, TestRulesToFilterTree deleted, contract-pin envelope keys
retracted per the contract_pins 2026-10-31 retirement entry. Mirrors
hand-synced: openapi.yaml, bruno create/update, docs/api/*.md,
docs/schema.go, api.d.ts. Full container suite green (155s).
2026-10-31 19:06:48 -04:00

2.0 KiB

method, path, auth, area
method path auth area
PUT /api/collections/:id jwt collections

Update Collection

Updates name/metadata, replaces the rule set, and merges view settings. Note the quirk: the success status is 201, not 200 (historical).

The playlist toggles hide_finished / show_up_next are accepted as top-level single-element arrays (an htmx form artifact — the LAST value wins) and are merged into view_settings server-side. JSON clients may prefer to set view_settings.hide_finished / view_settings.show_up_next directly.

Example request

{
  "name": "To Read (2026)",
  "description": "Updated description",
  "color": "#33CCFF",
  "icon": "📚",
  "view_settings": { "hide_finished": true },
  "hide_finished": ["true"],
  "show_up_next": ["true"]
}

Example response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "user_id": "8f14e45f-ceea-467f-a429-0b21bfc0b1a2",
  "name": "To Read (2026)",
  "description": "Updated description",
  "color": "#33CCFF",
  "icon": "📚",
  "view_settings": { "hide_finished": true, "show_up_next": true },
  "created_at": "2026-10-24 13:57:01.81234 +0000 UTC"
}

created_at uses Go's time.String() format, not RFC3339.

Request fields

Field Type Required Notes
name string yes
description string no
color string no
icon string no
view_settings object no merged into stored settings
filter_tree object no replaces the stored filter tree (omitting it keeps the stored one)
hide_finished array no single-element string array ["true"]/["false"]; merged into view_settings
show_up_next array no same shape as hide_finished

Errors

Status Body When
400 {"error": "invalid collection id"} / {"error": "invalid request"} malformed id or body
500 {"error": "..."} unexpected server error