Repository navigation
fix(sections): keep rule rows intact and create only the rows admins ask for - #1852
Conversation
…ask for The section editor's Easy filter mode replaced a multi-group rule row with one group on the first edit, and offered fields and operators the server rejects. Custom-filter rows now always use the rules editor the drawer already had, shown once, with personalized rules and sorts enabled because rows resolve per viewer. Rules the editor cannot represent, such as ones Easy saved, appear as labelled unsupported rules that stay as saved until removed. Easy, its quick-start templates and the unused preview box are gone. On the Admin Sections Home tab, "Apply to all libraries" created library rows instead of a Home row; it now shows only on the Library tab. The gallery "Add section" button is disabled while the create is in flight, so a double click no longer creates two rows. Admin single create and update skipped the recipe's own config check that bulk create, preview and profile saves run, so an empty Editor's Picks row could be saved. Create and any update that writes the type or config now run it; an update that writes neither leaves older rows editable. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The shared rule editor labelled every rule its controls cannot represent "Unsupported rule". Smart collections and the catalog filter sheet use the same editor, and their guided mode writes rules the server accepts, such as original language, author, narrator and series. Switching to Advanced then called those working rules unsupported and offered Remove, inviting users to delete a valid filter. The server also accepts the value shapes the editor cannot show, so the editor cannot tell a broken rule from a valid one. The row now reads "Not editable here" and still shows the rule, keeps it as saved, and offers Remove. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15f6c8fb44
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if msg, ok := validateRecipeConfig(sections.SectionType(req.SectionType), req.Config); !ok { | ||
| return none, apiError(http.StatusBadRequest, "bad_request", msg) | ||
| } |
There was a problem hiding this comment.
Preserve the frozen v1 create behavior
This service also backs POST /api/v1/admin/sections/, so the unconditional recipe check changes the frozen v1 route: a request such as an empty admin_curated_list, which the route previously stored, now returns 400. Keep this new validation in the v2 adapter or otherwise preserve the published bridge behavior rather than tightening both API versions through the shared service.
AGENTS.md reference: AGENTS.md:L226-L227
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 62e79b5. The recipe check is now opt-in on the shared service (ValidateRecipe, json:"-"), and only the /api/v2 adapter sets it, so POST/PUT /api/v1/admin/sections store what they stored before. A DB test pins v1 create and update of an empty Editor's Picks row, and an apiv2 test checks that v2 create and update request the check.
| if req.SectionType != "" || len(req.Config) > 0 { | ||
| if msg, ok := validateRecipeConfig(existing.SectionType, existing.Config); !ok { | ||
| return none, apiError(400, "bad_request", msg) |
There was a problem hiding this comment.
Validate actual recipe changes instead of echoed fields
When an existing row has recipe-invalid legacy config, the admin UI still cannot rename, move, or disable it: buildAdminSectionPayload and updateAdminSection always echo both section_type and config, even when the user changes only another field, so this condition revalidates the unchanged config and rejects the save. Compare the merged type/config with originalType/originalConfig, or make the UI submit a genuinely sparse PATCH, so the compatibility path described above this condition works in the primary editor.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 62e79b5. Update now runs the recipe check only when the merged type or config differs from the stored row (jsonConfigEqual against the original), so the editor's echoed section_type and config no longer block renaming, moving or disabling a legacy row. The DB test now disables an empty Editor's Picks row while echoing its unchanged type and config; it fails on the previous commit.
The recipe check on admin section create and update ran in the service that the frozen /api/v1 routes share with /api/v2, so v1 started rejecting configs it used to store. The check is now opt-in through a request field only the /api/v2 adapter sets. An update also re-ran the check whenever the request carried a type or config, but the admin editor echoes both on every save, so a legacy row with an invalid config still couldn't be renamed or disabled. The check now runs only when the merged type or config differs from the stored one. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: N/A
Validation tasks: changes #1141 C1-C2, #1137 AC1; may reach #194 A2, #195 W4 (shared rules editor)
Editing a row could break it without any warning, and the gallery could create rows the admin didn't ask for. This affected admins on Admin > Sections and profiles editing custom rows in Settings > Home Screen. The section editor's Easy filter mode rewrote rows with more than one rule group and saved rules the server rejects or can't run. On the Admin Sections Home tab, "Apply to all libraries" created library-page rows instead of a Home row. A fast double click on the gallery's "Add section" could create the row twice, and the single-row admin endpoints saved an Editor's Picks row with no titles. This change removes Easy mode, offers the bulk option only on the Library tab, disables "Add section" while its request runs, and has admin create and update check the config against the section type's own rules.
contains, which onlygenreaccepts, so admin saves failed with a 400. It saved "Has been watched" andbetweenvalues as text, so the row failed when it loaded.library-scope rows, never a Home row.Approach
original_languageandauthor. Many of these rules are valid, so the label doesn't call them broken./api/v2admin create runs the section type's own config check. Update runs it only when the merged type or config differs from the stored one, so a row saved before this change can still be renamed, moved or disabled, including from the admin editor, which sends the unchanged type and config back with every save. A failed check returnsvalidation_failed(422), which both operations already document. The check is opt-in on the shared service, and only the/api/v2adapter requests it, so the frozen/api/v1single create and update routes behave as before.docs/architecture/api-contract.mdnow says when the check runs.Validation
go build ./...,gofmt,go vetandmake lint-changedare clean.go testpasses forinternal/api/handlers,internal/api,internal/apiv2,internal/sections/...andcmd/silo, including new tests that/api/v2create and update request the check and that admin create rejects an empty Editor's Picks row. The fullmake test-gowas not run./api/v1create and update still store an empty row. These fail on the previous commit and pass now.make verify-apiv2-openapi,make verify-apiv2-contract,make verify-apiv2-fixturesandTestCommittedArtifactMatchesRouterpass. The OpenAPI artifact is unchanged.make test-webpasses. New tests cover an untouched rule row saving byte-identical config in admin and profile modes, personalized rules staying editable, read-only rules being kept or removed, no bulk option on the Home tab, and a double click sending one create request.pnpm run lintreports no errors; its warnings in changed files are on exports that already existed.pnpm run format:check,pnpm run buildandpnpm run budget:checkpass.make verify-local-pathspasses.Risks
/api/v2clients that create or edit admin sections now getvalidation_failedfor configs that used to be accepted.Checklist
AI Disclosure
tsc -b, ESLint and Prettier. It found one minor issue: the shared rules editor labelled valid rules it can't edit "Unsupported rule", for example Guided-vieworiginal_languageorauthorrules in smart collections, which could lead users to delete working filters. The label now reads "Not editable here", and a test checks that a Guided-view rule isn't called unsupported. It also noted that the v1 bridge routes now ran the section type's check. After the PR opened, an automated review flagged the same v1 change and that the editor's echoed config still blocked saves on legacy rows; both are fixed: the check is opt-in for/api/v2only and runs only when the type or config actually changes.🤖 Generated with Claude Code
Note
Add recipe config validation for admin section writes and remove FilterEasyMode UI
SectionHandler.CreateAdminSectionandUpdateAdminSectionin admin_sections_service.go. The v2 adapters setValidateRecipe: true; the frozen/api/v1routes keep the old no-check behavior. Updates run the check only whensection_typeorconfigactually changes.CollectionRulesEditorin SectionEditorDrawer.tsx. Rules the editor cannot safely represent render read-only viacanEditRuleand stay in the config until explicitly removed.FilterEasyModecomponent set and its conversion module (filterEasyMode.ts and components underweb/src/components/FilterEasyMode/).RecipeConfigDrawer.handleAddagainst double submission: the Add section button disables while the create promise is pending and re-enables after it settles./api/v2now reject invalid recipe configs with a 400; PATCHes that only change other fields or echo unchanged definition fields still succeed.Macroscope summarized 62e79b5.