Skip to content

fix(content): name the label or item blocking a root hand-over - #521

Open
CloudCorpRecords wants to merge 2 commits into
gopherium:mainfrom
CloudCorpRecords:fix/refusal-messages-name-target
Open

CloudCorpRecords wants to merge 2 commits into
gopherium:mainfrom
CloudCorpRecords:fix/refusal-messages-name-target

Conversation

@CloudCorpRecords

@CloudCorpRecords CloudCorpRecords commented Oct 19, 2026 •

Copy link
Copy Markdown

Closes #513

What changed

A refused Make default now says what to fix, one message per case:

  • When the old default type's plural name would become a route word Gophenberg keeps (e.g. page), the hand-over refusal is now code route_word_reserved_by_label carrying the label and the word. The admin message names the plural name and says to change it, instead of pointing at a route word field the Make default flow does not have.
  • When an item would land on a root pagination address (e.g. page/2), the refusal is now code pagination_address_reserved carrying the path. The admin message names the address and says to give the item a different slug.

Both codes are new. The plain route_word_reserved and address_reserved codes keep their existing messages for the direct-edit flows where that advice is right. The refusal constructors (content.LabelRouteWordReserved, content.PaginationAddressReserved) sit in the content package next to the existing ones; the postgres store and the in-memory test store emit them alike. The new strings are translated to Spanish and French following the repo's i18n pattern (.pot regenerated with pnpm pot, translations drafted in the .po files, JSON catalogs rebuilt with pnpm catalogs).

Testing

  • go test ./internal/content/... passes, including with -race.
  • go test ./internal/server/ passes except TestUploadingMediaMasksAFailingLibrary, which also fails on unmodified main (pre-existing, unrelated to this change).
  • go test ./test/features/ -run 'TestContentTypes|TestContentServing|TestTypeStoreSuite|TestContentStoreSuite' passes (godog feature suite plus the store contract suites, memory stores).
  • New and updated Go coverage: typestore step arms pin the exact refusal value for both hand-over cases; contenttest contract cases assert the new codes and their details on every store; server tests assert the API answers 422 with the new codes and meta; postgres tests pin code and details too (need a database, so not run locally).
  • Frontend: vitest run src/test/errors.test.ts passes (15 tests, including the every-code-has-a-message coverage test and two new template tests); pnpm typecheck, pnpm -w lint, gofmt and go vet are clean.
  • The updated tests were watched failing before their expectations were updated, confirming they exercise the new behavior.

Summary by CodeRabbit

  • Bug Fixes
    • Clarified errors when an item slug conflicts with an address reserved for front-page pagination.
    • Clarified errors when a content type’s plural label would create a reserved route word.
    • Error responses now identify the conflicting path, label, or route word to make corrections easier.
    • Reserved-route validation is applied consistently when changing the default content type.
    • Added Spanish and French translations for both messages.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: gopherium/gophenberg/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 681a28fa-dd80-4ac3-a03a-8bf1ca481f5a
📥 Commits

Reviewing files that changed from the base of the PR and between 10d9528 and 8cdcb4c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: gopherium/gophenberg/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dc092d54-d2c8-467d-856b-d8ee2b2596a8
📥 Commits

Reviewing files that changed from the base of the PR and between bd1b526 and 10d9528.

📒 Files selected for processing: 1
  • internal/content/refusals_test.go

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

📝 Walkthrough

The change adds specific error codes and details for reserved pagination addresses and route words derived from plural labels. Root-handover and pagination checks use these refusals. Tests, frontend messages, and translation catalogs cover both errors.

Changes: Reserved Route Refusals

Layer / File(s) Summary
Reserved-route error contracts
internal/content/paths.go, internal/content/types.go, internal/content/refusals_test.go, internal/content/contenttest/root_pagination.go
Content adds refusal constructors for reserved pagination addresses and route words derived from plural labels. Tests check error identity, codes, details, and messages.
Root handover and pagination validation
internal/content/typestore/..., internal/postgres/pagination.go, internal/postgres/pagination_test.go, test/features/content-types.feature, test/features/memorycontent_test.go, test/features/memorytypes_test.go
Type handovers return a label-specific refusal for reserved route words. Pagination checks use the reserved-address refusal. In-memory and PostgreSQL tests check the codes and details.
Error responses and messages
internal/server/content_helpers_test.go, internal/server/pagination_reserved_test.go, frontend/src/i18n/errorTemplates.ts, frontend/src/test/errors.test.ts, languages/*
Server tests check 422 responses and metadata for both errors. Frontend messages, tests, and translation catalogs cover reserved addresses and route words.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 10d95

The selected tests cover the new refusal details, and no merge-blocking issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 65.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: root hand-over refusals now identify the blocking label or item.
Linked Issues check Passed Issue #513 is active and directly linked. LabelRouteWordReserved returns route_word_reserved_by_label with label and word details. PaginationAddressReserved returns `pagination_address_reser…
Out of Scope Changes check Passed The changes stay within issue #513. Store, server, and content changes provide the two required refusal cases. Tests verify codes, details, HTTP metadata, and rendered messages. Catalog updates and tr…
Full details: Linked Issues check

Explanation

Issue #513 is active and directly linked. LabelRouteWordReserved returns route_word_reserved_by_label with label and word details. PaginationAddressReserved returns pagination_address_reserved with path details. The frontend templates name the conflicting label, route word, or address and state the required fix. Spanish and French translations and automated tests cover the new messages and refusal data.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #513. Store, server, and content changes provide the two required refusal cases. Tests verify codes, details, HTTP metadata, and rendered messages. Catalog updates and translations support the required wording. No unrelated product behavior is shown.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

codescene-access[bot]

This comment was marked as outdated.

Comment thread internal/content/paths.go
Comment thread internal/postgres/pagination.go
Comment thread internal/content/contenttest/root_pagination.go
Comment thread languages/gophenberg.pot
gitar-bot[bot]

This comment was marked as resolved.

@CloudCorpRecords
CloudCorpRecords force-pushed the fix/refusal-messages-name-target branch from e6f2a81 to bd1b526 Compare October 19, 2026 20:46
codescene-access[bot]

This comment was marked as outdated.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

The PR names the plural label or item address that blocks Make default.

  • A root hand-over names the plural label that creates a reserved route word.
  • A pagination conflict names the address an item cannot take.

No new actionable issues were found. Neither numbered previous finding remains outstanding.

Reviews (2) · Last reviewed commit: "test(content): pin the two new refusal c..." · Reviewed by Greptile

Comment thread internal/postgres/pagination.go
Comment thread frontend/src/languages/es-ES.json
@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Server tests use missing type internal/server/content_helpers_test.go:455 ▶

    server.UserStore does not exist. server.Config.Users still uses authkit.AdminStore, so changing these test helpers to the missing type prevents the server tests from compiling. Keep the existing type or add the intended replacement.

  • P1 Query returns too few values internal/postgres/pagination.go:39 ▶

    MoveDescendants returns only an error, but this call expects both paths and an error. This prevents the Postgres package from compiling. Update the SQL query and regenerate its Go method to return the moved paths, or change the helper to match the existing method.

codescene-access[bot]

This comment was marked as outdated.

@gitar-bot
gitar-bot Bot dismissed their stale review October 20, 2026 15:26

✅ All code review findings resolved.

Configure merge blocking

A refused Make default now says what to fix. When the old default
type's plural name would become a route word Gophenberg keeps (page),
the refusal names the label and the word it makes and says to change
the plural name, instead of pointing at a route word field the flow
does not have. When an item would land on a root pagination address
(page/2), the refusal names the address and says to give the item a
different slug.

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
PaginationAddressReserved and LabelRouteWordReserved had no tests in
the content package itself, so codecov reported their lines uncovered.
Add package level tests asserting the sentinel, the code, the details
and the message for both constructors.

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
@CloudCorpRecords
CloudCorpRecords force-pushed the fix/refusal-messages-name-target branch from 10d9528 to 8cdcb4c Compare October 20, 2026 21:27
@gitar-bot

gitar-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 closed / 4 findings

🔴 High risk · Replacing refusal codes for root handovers and pagination conflicts changes API error contracts, which could break clients matching the previous codes.

Adds distinct refusal codes route_word_reserved_by_label and pagination_address_reserved so Make default refusals name the label or item to change, with Spanish and French translations. Four issues were resolved this session, including a content package build failure, non-compiling postgres pagination helpers, unregistered contract cases, and regenerated catalogs dropping strings the frontend uses. No open findings remain.

✅ 4 closed
✅ Bug: content package fails to build: RootPagination and slugOf undefined

📄 internal/content/paths.go:108-110 📄 internal/content/types.go:220-227 📄 internal/postgres/pagination.go:15 📄 internal/postgres/pagination.go:24 📄 test/features/memorycontent_test.go:516 📄 test/features/memorycontent_test.go:864 📄 test/features/memorycontent_test.go:993
go vet ./internal/content/... fails with paths.go:108:5: undefined: RootPagination and types.go:222:10: undefined: slugOf. Neither symbol is defined anywhere in the repo. Only Slugify exists in content.go:97. RootPagination is also called from internal/postgres/pagination.go and test/features/memorycontent_test.go, so every package that imports content fails to compile. This contradicts the PR's statement that go test ./internal/content/... passes. The PR looks like it was cut from a branch with an unmerged prerequisite. Fix: add RootPagination(path string) bool (true for page/<n>) to paths.go, and either use Slugify or add slugOf.

✅ Bug: postgres pagination helpers don't compile and are never called

📄 internal/postgres/pagination.go:22-36
moveDescendants assigns paths, err := queries.MoveDescendants(ctx, params). The generated MoveDescendants is a :exec query that returns only error (db/content.sql.go:1018,1040), so this assignment does not compile. Also, checkPaginationEdit, moveDescendants and checkPaginationPaths have no callers. internal/postgres/content.go:380 still calls queries.MoveDescendants directly. So even once the code compiles, the postgres store never returns pagination_address_reserved, while the new postgres and contract tests expect it. Fix: change the query to :many with RETURNING path and regenerate sqlc. Then route Create, Update and the descendant move through these helpers.

✅ Bug: New contract cases use undefined helpers and are never registered

📄 internal/content/contenttest/root_pagination.go:14-28 📄 internal/content/contenttest/root_pagination.go:258 📄 internal/content/contenttest/root_pagination.go:261 📄 internal/content/contenttest/root_pagination.go:284
root_pagination.go calls relabelPost and rootPage, but neither is defined in contenttest. The only fixtures there are PageType, RegisterPageType, MustNest and similar. The new rootPaginationCases and typeRootPaginationCases slices are not referenced by any suite, so even after the code compiles, none of these cases runs against the memory or postgres stores. Fix: add the two helpers and append the slices to the content and type case lists the suites iterate.

✅ Bug: Regenerated .pot/.po drop strings the frontend still uses

📄 languages/gophenberg.pot:353-356 📄 languages/gophenberg.pot:1773-1782 📄 languages/gophenberg.pot:1805 📄 languages/es-ES.po:66 📄 languages/es-ES.po:105 📄 languages/es-ES.po:278-283 📄 languages/es-ES.po:674 📄 languages/fr-FR.po:203 📄 languages/fr-FR.po:281 📄 languages/fr-FR.po:579 📄 languages/fr-FR.po:587 📄 languages/fr-FR.po:1350 📄 languages/fr-FR.po:1546 📄 languages/fr-FR.po:2571 📄 frontend/src/languages/es-ES.json
The .pot and catalogs seem to have been generated from a different source tree. They remove msgids that the current code still renders: Add media (media/MediaScreen.tsx:162), Home and Welcome to Gophenberg. (Home.tsx), Back (ContentSidebar.tsx), and Install theme and Theme archive (ThemesScreen.tsx). They also delete the weekday, month and date-format entries. At the same time they add strings that appear nowhere in frontend/src, such as Upload media, Drop files to upload and Manage the posts on this site.. With the translations removed from es-ES/fr-FR .po and the rebuilt JSON catalogs, Spanish and French admins will see these labels in English. Fix: rerun pnpm pot and pnpm catalogs from this branch, so the only i18n changes are the two new messages.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Failed
Prevent hotspot decline (1 hotspot with Bumpy Road Ahead)
Enforce critical code health rules (1 file with Bumpy Road Ahead)
Enforce advisory code health rules (1 file with Large Method)

Our agent can fix these. Install it.

Gates Passed
1 Quality Gates Passed

Reason for failure
Prevent hotspot decline Violations Code Health Impact
memorytypes_test.go 1 rule in this hotspot 7.61 → 7.55 Suppress
Enforce critical code health rules Violations Code Health Impact
memorytypes_test.go 1 critical rule 7.61 → 7.55 Suppress
Enforce advisory code health rules Violations Code Health Impact
errorTemplates.ts 1 advisory rule 7.44 → 7.41 Suppress

See analysis details in CodeScene

Absence of Expected Change Pattern

  • gophenberg/internal/content/types.go is usually changed with: gophenberg/internal/content/registry_internal_test.go

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Say which label or item blocks a root hand-over

1 participant