Conversation
…n-proof (COR-444) The 400s on `problems-*` creates were never about the article body. Every `problems/*.mdx` whose file name carries an underscore failed `POST /articles` with 400 (19 pages), while `problems/conflict`, `problems/forbidden`, and `problems/gone` created fine. FernDesk accepts a slug only in `[a-z0-9]+(-[a-z0-9]+)*`, and this repo mirrors the backend's snake_case `ErrorCode` names as file names. `#17` fixed the symptom by chaining `.replace("_", "-")` onto the slug. This commit makes the rule explicit and guards it: - `sanitize_slug()` states the FernDesk charset in one place: lowercase, every run of other characters collapsed to one hyphen, ends trimmed. It raises rather than emitting an empty slug. - `discover_pages()` refuses to sync when two paths sanitize to one slug (`a_b.mdx` + `a-b.mdx`), which would otherwise silently overwrite an article. - `ferndesk-sync-retry.test.py` runs `discover_pages` over this repository and fails if a problem page yields an illegal slug, keeps an underscore, collides with another page, or keeps a bare snake_case title. 13 new checks (62 total). - `FERNDESK.md` documents why the MDX file names cannot be renamed: they match `ErrorCode::as_str` and the page's `/problems/{code}` type URI. Behavior is unchanged for every current page: all 99 slugs are byte-identical to before this commit, and titles/markdown are untouched. The guard is proven by mutation: reverting `sanitize_slug` to the underscore-preserving form fails 8 checks. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DRAFT — do not merge. Opened for review only.
Why the
problems-*pages failedEvery
problems/*.mdxwhose file name contains an underscore failedPOST /articleswith 400 (19 pages). The five codes without an underscore —conflict,forbidden,gone,internal,unauthenticated— created fine.Evidence from run 34902589600 (
11d7114, before the slug fix):The discriminator is the slug, not the article body: the failed set is exactly the 19 slugs containing
_, and tables, JSON fences, and em dashes all appear in pages that synced successfully.FernDesk accepts a slug only in
[a-z0-9]+(-[a-z0-9]+)*. This repo mirrors the backend's snake_caseErrorCodenames as file names, soproblems/bad_requestwas sent verbatim and rejected.#17(b229ee9) fixed the symptom. Its follow-up run 34905578558 created 17 of the 19 pages with zero 400s; the two remaining failures are429 rate_limitedonproblems-service-unavailableandproblems-unsupported-media-type, i.e. quota, not the slug bug:What this PR adds
#17expressed the rule as a chained.replace("_", "-")with no test behind it. This PR makes the rule explicit and guards it:scripts/ferndesk_sync.pysanitize_slug()states the FernDesk charset in one place: lowercase, every run of other characters (_,/, spaces,--) collapsed to a single hyphen, ends trimmed. It raises rather than emitting an empty slug.discover_pages()refuses to sync on a slug collision. Two paths that sanitize to one slug (a_b.mdxanda-b.mdx) would otherwise silently overwrite one article via the upsert-by-slug path.scripts/tests/ferndesk-sync-retry.test.py— 13 new checks (62 total), still fully offline:discover_pagesrun over this repository: every problem page must yield a FernDesk-legal slug, keep no underscore, keep a bare snake_case title out of the title, and not collide repo-wide;discover_pagesraises instead of overwriting.scripts/FERNDESK.mddocuments the rule and why the MDX file names cannot simply be renamed: they matchErrorCode::as_strand the page's/problems/{code}type URI, so the sanitization belongs at the sync boundary.Behavior change
None for current content. All 99 discovered slugs are byte-identical to before this commit, and titles/markdown are untouched. The new tests are proven to bite by mutation: reverting
sanitize_slugto the underscore-preserving form fails 8 checks.Test plan
Mutation check: with
sanitize_slugreverted toreplace("/", "-"), the suite fails 8 checks (exit 1).Not claimed
No live API write was attempted from this session. The remaining
429on the two pending pages is FernDesk write quota, not this bug; a re-run of the sync workflow once the limit clears should land them. The FernDesk UI still needs Connect domain fordocs.cortex.foundationHTTPS, which is separate operator work.