Skip to content

fix: stop upload path segments from retargeting API requests - #1557

Merged
erunion merged 4 commits into
nextfrom
fix/changelogs-frontmatter
Nov 11, 2026
Merged

erunion merged 4 commits into
nextfrom
fix/changelogs-frontmatter

Conversation

@erunion

@erunion erunion commented Nov 10, 2026 •

Copy link
Copy Markdown
Member
🚥 Resolves RM-19535, RM-18181, RM-19533

Summary

The hidden rdme changelogs command copied each file's frontmatter slug into /api/v1/changelogs/${slug} and spread the rest of the frontmatter into the update body. fetch resolves .. and %2e%2e before the request is sent, so a slug such as ../docs/victim could GET and PUT a different v1 resource in the same project.

The same interpolation was still in the v2 page uploader and in OpenAPI upload. A frontmatter slug could retarget GET/PATCH for guides, reference, custom pages, and changelogs. --useSpecVersion put info.version in /branches/${version}/apis, and --slug (or the inferred filename) was placed raw in /branches/${branch}/apis/${filename}.

  • assertSlug in src/lib/slug.ts rejects a value that is not one path segment, including percent-encoded dot segments, ?, #, and ASCII controls. Request paths use encodeURIComponent. The error names the value as a slug or a branch.
  • A directory upload checks every page slug, and the branch when the route has one, before the first page request.
  • Page GET and PATCH encode the slug. The branch is encoded in the route and in normalized category and parent URIs.
  • OpenAPI upload checks the branch (--branch, or info.version with --useSpecVersion) before listing definitions, and checks the filename after --slug and --legacy-id are applied. Both are encoded in the request URL. Matching and logs keep the raw values.
  • The legacy changelog request body is limited to title, type, hidden, metadata (description, image, keywords, title), body, and lastUpdatedHash. slug is set only on create. Dry run prints that body.
  • Changelog files are sorted in a Map, so a slug of __proto__ is not stored on an object prototype.
  • GitHub Actions workflow-command snapshots no longer change when the package version or a local proxy changes.

Test plan

  • npx vitest run test/lib/slug.test.ts test/commands/changelogs/index.test.ts test/commands/changelogs/single.test.ts test/commands/pages/upload.test.ts test/commands/changelog/upload.test.ts test/commands/openapi/upload.test.ts test/lib/ghaWorkflowCommands.test.ts
  • A changelog whose slug is ../docs/victim, %2e%2e, or x?foo=1 fails before any API request, including when a sibling file in the same directory is valid.
  • A slug of 100% is encoded in the path and sent raw in the create body.
  • Frontmatter metadata.keywords is sent. category, htmlmode, and parentDocSlug are not.
  • Dry run prints the request body, not the raw frontmatter.
  • A docs or reference directory with slug ../../stable/<route>/victim fails before that page or a sibling is requested.
  • --branch ../projects/me fails before the page request. A slug of 100% and a branch of 1.0+beta are encoded in the path.
  • openapi upload --useSpecVersion with info.version of ../../projects/me fails before /branches/.../apis.
  • openapi upload --slug ../secret.json fails after the branch listing and before the upload request.

Frontmatter slugs were placed unencoded in the v1 path, and the rest of the frontmatter was spread into the update body.

Co-authored-by: Cursor <cursoragent@cursor.com>
@erunion erunion added the bug Something isn't working label Nov 10, 2026
@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The latest change appears safe to merge.

Reviews (5) · Last reviewed commit: "fix: bad nockmock" · Reviewed by Greptile

Comment thread test/commands/changelogs/index.test.ts Resolved
@erunion
erunion marked this pull request as draft November 10, 2026 23:50
Co-authored-by: Cursor <cursoragent@cursor.com>
@erunion erunion changed the title fix(changelogs): stop the legacy sync from retargeting v1 requests fix: stop upload path segments from retargeting API requests Nov 10, 2026
erunion and others added 2 commits November 10, 2026 16:26
v1.0-alpha is already one URL segment, so the branch check does not need a second grammar. Page sorting uses a Map so __proto__ and constructor stay real keys, and category URIs keep the raw branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
@erunion
erunion marked this pull request as ready for review November 11, 2026 00:31
@erunion
erunion merged commit f35a295 into next Nov 11, 2026
10 checks passed
@erunion
erunion deleted the fix/changelogs-frontmatter branch November 11, 2026 00:35
erunion pushed a commit that referenced this pull request Nov 11, 2026
## [10.10.1-next.2](v10.10.1-next.1...v10.10.1-next.2) (2026-11-11)

### Bug Fixes

* stop upload path segments from retargeting API requests ([#1557](#1557)) ([f35a295](f35a295))

[skip ci]
@erunion

erunion commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

🎉 This PR is included in version 10.10.1-next.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

erunion pushed a commit that referenced this pull request Nov 11, 2026
## [10.10.2-next.1](v10.10.1...v10.10.2-next.1) (2026-11-11)

### Bug Fixes

* stop upload path segments from retargeting API requests ([#1557](#1557)) ([f35a295](f35a295))

[skip ci]
@erunion

erunion commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

🎉 This PR is included in version 10.10.2-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

bug Something isn't working released on @next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant