Skip to content

fix(core): reject writes with an oversized path segment#353

Merged
khaliqgant merged 1 commit into
mainfrom
fix/max-path-segment-length
Jul 15, 2026
Merged

fix(core): reject writes with an oversized path segment#353
khaliqgant merged 1 commit into
mainfrom
fix/max-path-segment-length

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Local relayfile mounts materialize each path segment as a real filesystem entry. Most filesystems (ext4, APFS, ...) reject names over 255 bytes with ENAMETOOLONG — worse once a mount's own atomic-write suffix (.tmp-<random>) is appended to the leaf segment.
  • A provider adapter that builds a path segment from unbounded content (a long title, etc.) could produce a canonical path no mount could ever materialize. Since nothing revisits an already-written path, that failure recurs forever on every sync cycle for that one file — no self-heal, no automatic recovery.
  • Root cause of the incident this generalizes a fix for: relayfile-adapters#241 capped the reddit post title slug after a 275-byte segment made the reddit-monitor persona's sandbox mount fail continuously (mount sync cycle failed: ... file name too long, repeating indefinitely). That was a point fix in one provider adapter. This PR adds a shared guard at the two write entry points in @relayfile/corewriteFile (direct HTTP write API) and applyWebhookEnvelope (Nango/webhook sync path, the one that actually created the original bad file) — so no provider adapter can reintroduce this class of bug, ever.
  • New MAX_PATH_SEGMENT_BYTES = 200 (comfortably under the 255-byte filesystem limit, leaving margin for mount-side suffixes) checked against each path segment's UTF-8 byte length, not JS string length.

Test plan

  • packages/core/src/files.test.ts (new): unit tests for hasOversizedPathSegment, including UTF-8 byte-length correctness and a reproduction of the exact real oversized r/LocalLLaMA path that broke the mount. Plus writeFile integration tests confirming the guard rejects before touching storage and a normal path still proceeds.
  • packages/core/src/webhooks.test.ts: new test confirming applyWebhookEnvelope rejects an oversized-path envelope with reason: "path_too_long" and never writes it to storage.
  • Full packages/core suite: 42/42 pass (was 34 before this PR).
  • npm run build in packages/core — clean.

Note

This does not retroactively fix any already-written oversized-path file (e.g. the specific stuck reddit-monitor orphan) — it only prevents new ones. That cleanup is tracked separately since it touches append-only production event history in relayfile-cloud, not this repo.

Review in cubic

Local relayfile mounts materialize each path segment as a real
filesystem entry. Most filesystems (ext4, APFS, ...) reject names over
255 bytes with ENAMETOOLONG -- worse once a mount's own atomic-write
suffix (e.g. `.tmp-<random>`) is appended to the leaf segment. A
provider adapter that builds a path segment from unbounded content (a
long title, etc.) could produce a canonical path no mount could ever
materialize, and since nothing revisits an already-written path,
that failure recurred forever on every sync cycle.

Root cause of the incident this fixes: relayfile-adapters#241
capped the reddit post title slug after a 275-byte segment made the
`reddit-monitor` persona's sandbox mount fail continuously. That was
a point fix in one provider adapter; this adds a shared guard at both
write entry points (`writeFile` and `applyWebhookEnvelope`) so no
provider can reintroduce the same class of bug.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@khaliqgant, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86a86c89-0ed6-4829-ae09-6e2ab27241d0

📥 Commits

Reviewing files that changed from the base of the PR and between 10f4472 and 06b1708.

📒 Files selected for processing (4)
  • packages/core/src/files.test.ts
  • packages/core/src/files.ts
  • packages/core/src/webhooks.test.ts
  • packages/core/src/webhooks.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/max-path-segment-length

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.

@github-actions

Copy link
Copy Markdown

Relayfile Eval Review

Run: .relayfile/evals/runs/2026-07-15T18-01-05-950Z-HEAD-provider
Mode: provider
Git SHA: 85b915d

Passed: 4 | Needs human: 0 | Reviewable: 0 | Missing output: 0 | Failed: 0 | Skipped: 0

Human Review Cases

No reviewable human-review cases captured Relayfile output.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

Re-trigger cubic

@khaliqgant
khaliqgant merged commit 6f15c9e into main Jul 15, 2026
10 checks passed
@khaliqgant
khaliqgant deleted the fix/max-path-segment-length branch July 15, 2026 20:45
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.

1 participant