fix: refactor formatExceptionMessage to accept generic request context#2877
Conversation
|
Caution Review failedAn error occurred during the review process. Please try again later. WalkthroughUpdated exception formatting by introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR is a focused, low-risk refactor of
Confidence Score: 5/5Safe to merge — pure cosmetic/label refactor with no logic changes and no call-site modifications required. The only changed lines are a parameter rename and a template-literal label string. There are no logic changes, no type signature breaking changes, and all 11 call sites are unaffected. No P0 or P1 issues were found. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Render as Render Endpoint
participant Upload as Upload-Assets Endpoint
participant FEM as formatExceptionMessage(requestDescription, error, context?)
participant Log as Error Log
Render->>FEM: JS code string (e.g. bundle contents)
Upload->>FEM: Task description string (e.g. "Uploading bundles [server.js]…")
FEM->>Log: "Request:\n{smartTrim(requestDescription)}\nEXCEPTION MESSAGE: …"
Reviews (1): Last reviewed commit: "fix: rename formatExceptionMessage param..." | Re-trigger Greptile |
|
Overall: clean, focused fix. The rename and label change correctly address the misleading output in upload-assets error logs. No blocking issues - all 11 call sites were verified. Minor notes: (1) The label 'Request:' is quite terse; for render paths the content is JS code, for upload paths it is a task description - something like 'Request context:' would be marginally clearer in logs. (2) worker.ts lines 326/334 still pass a variable named renderingRequest while upload-assets callers use requestContext - no change required, just a mild naming inconsistency. (3) Pre-existing trailing whitespace on line 70 of utils.ts in the template literal blank line. |
| return `${context ? `\nContext:\n${context}\n` : ''} | ||
| JS code for rendering request was: | ||
| ${smartTrim(renderingRequest)} | ||
| Request: |
There was a problem hiding this comment.
The label Request: is correct in that it applies to both JS-code render requests and task-description upload requests, but it is quite terse for a debugging log. When scanning error output it's not immediately clear what the content beneath it represents (raw JS? a URL? a task name?).
| Request: | |
| Request context: |
A slightly more descriptive label would still be generic enough to cover both callers while giving more signal to someone triaging a production error. Either way this is not a blocker.
There was a problem hiding this comment.
Addressed — updated to Request context: in 63e2105. Also removed the trailing whitespace on the blank line.
size-limit report 📦
|
|
Code Review: The change is well-motivated and the implementation is correct. A few items worth noting: (1) CHANGELOG entry missing: per AGENTS.md, user-visible bug fixes need a CHANGELOG.md entry with a [Pro] prefix. Changing the error label is observable in production logs. (2) PR description says the new label is 'Request:' but the code uses 'Request context:' — worth keeping accurate. (3) Label confusion: when context is provided the output contains both 'Context:' and 'Request context:', using the word context with different meanings. A cleaner label would be 'Request:' or 'Request details:'. (4) Good catch removing the trailing whitespace after the request snippet. |
| JS code for rendering request was: | ||
| ${smartTrim(renderingRequest)} | ||
| Request context: |
There was a problem hiding this comment.
The label "Request context:" clashes with the "Context:" label that appears just above it in the same output when context is provided:
Context:
Error in a rendering stream ← the "context" param
Request context: ← confusingly similar label
<JS code or task description>
The PR description says the intended label is "Request:" — that shorter form avoids the ambiguity. Consider:
| Request context: | |
| Request: |
There was a problem hiding this comment.
Good catch — reverted to plain Request: in 16d6458. The clash with the Context: section above was a clear issue.
ReviewClean, well-scoped fix. The rename and label change are correct, and the PR description accurately reflects the final code. Must fix: CHANGELOG entry missing. Per AGENTS.md, user-visible bug fixes require a CHANGELOG entry. Changing the error log label is observable in production logs (operators watching for patterns in error output would see a different string). Add an entry under Minor notes (non-blocking):
|
| JS code for rendering request was: | ||
| ${smartTrim(renderingRequest)} | ||
| Request: |
There was a problem hiding this comment.
The label Request: is a clear improvement over the render-specific old label and works correctly for both call sites. One thing worth considering: when context is also provided, the output reads:
Context:
<context>
Request:
<requestDescription>
The word "context" is now used for two different things — the outer context parameter and the surrounding phrase "request context." Not blocking, but Request details: or Request input: would make the two sections visually distinct.
Also note: this file needs a CHANGELOG entry — the label change is user-visible in production logs and qualifies as a **[Pro]** bug fix per AGENTS.md.
There was a problem hiding this comment.
Per the changelog guidelines: "Do NOT add entries for: linting, formatting, refactoring, tests, or documentation fixes." This is a parameter rename + label change (refactoring), so no CHANGELOG entry is needed.
Regarding the label name — Request: is what the issue specifies, and both Request details: and Request input: add words without meaningfully disambiguating from Context:. Keeping Request: as-is.
…ntext (#2858) The function hardcoded "JS code for rendering request was:" which was misleading when called from the /upload-assets endpoint with a task description string. Rename the parameter from `renderingRequest` to `requestDescription` and change the label to the neutral "Request:". No caller changes needed - all 11 call sites already pass a string. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Address review feedback: use a more descriptive label than bare "Request:" for better log clarity, and remove pre-existing trailing whitespace in the template literal. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
'Request context:' is ambiguous when the optional 'Context:' section is also present in the same error output. Plain 'Request:' is unambiguous and matches the original PR intent. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…r-specific label
Rendering callers now pass { renderingRequest } and get the original
"JS code for rendering request was:" label, while non-rendering callers
(upload-assets) pass { label, content } with an explicit label.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
630c5e8 to
b05027b
Compare
| return badRequestResponseResult(msg); | ||
| } | ||
|
|
||
| export type RequestInfo = { renderingRequest: string } | { label: string; content: string }; |
There was a problem hiding this comment.
Missing blank line between the type export and the JSDoc comment — the JSDoc currently reads as if it documents the type, not formatExceptionMessage.
| export type RequestInfo = { renderingRequest: string } | { label: string; content: string }; | |
| export type RequestInfo = { renderingRequest: string } | { label: string; content: string }; | |
| // See https://github.com/shakacode/react_on_rails/issues/2463 | ||
| const result = await handleNewBundlesProvided(taskDescription, providedNewBundles, assetsToCopy); | ||
| const result = await handleNewBundlesProvided( | ||
| { label: 'Request:', content: taskDescription }, |
There was a problem hiding this comment.
'Request:' is quite generic in an error log — consider something like 'Upload task:' to make it immediately clear in a log tail that this error came from the upload-assets path rather than a render request.
Review: fix: refactor formatExceptionMessage to accept generic request contextThe change is well-motivated and correctly solves the misleading label problem for the Found issues (all minor):
No test gaps that need addressing — the Overall: LGTM with the three minor nits above addressed. |
#2877) ## Summary - Renamed `renderingRequest` parameter to `requestDescription` in `formatExceptionMessage` - Changed the hardcoded label from `"JS code for rendering request was:"` to the neutral `"Request:"` - Updated JSDoc to reflect the broader usage Closes #2858 ## Context `formatExceptionMessage` was originally written for the render endpoint and hardcoded the label `"JS code for rendering request was:"`. Since the `/upload-assets` endpoint now also calls it (via lock-failure handling) with a task description string like `"Uploading bundles [server.js] with assets [stats.json]"`, this produced misleading error logs. The fix uses a generic label that works for both use cases. All 11 call sites already pass a `string`, so no caller changes were needed. ## Test plan - [x] TypeScript type-check passes (`pnpm run --filter react-on-rails-pro-node-renderer type-check`) - [x] ESLint passes on the changed file - [x] Package builds successfully (`pnpm run --filter react-on-rails-pro-node-renderer build`) - [x] Verified all 11 call sites — no caller changes required 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved rendering error messages to clearly show the request context, choosing a descriptive label when a JS rendering snippet is present or using a provided custom label/content. * Simplified the default label to "Request:" where applicable. * Trimmed and cleaned surrounding whitespace/newlines so error snippets and overall output are easier to read. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
#2877) - Renamed `renderingRequest` parameter to `requestDescription` in `formatExceptionMessage` - Changed the hardcoded label from `"JS code for rendering request was:"` to the neutral `"Request:"` - Updated JSDoc to reflect the broader usage Closes #2858 `formatExceptionMessage` was originally written for the render endpoint and hardcoded the label `"JS code for rendering request was:"`. Since the `/upload-assets` endpoint now also calls it (via lock-failure handling) with a task description string like `"Uploading bundles [server.js] with assets [stats.json]"`, this produced misleading error logs. The fix uses a generic label that works for both use cases. All 11 call sites already pass a `string`, so no caller changes were needed. - [x] TypeScript type-check passes (`pnpm run --filter react-on-rails-pro-node-renderer type-check`) - [x] ESLint passes on the changed file - [x] Package builds successfully (`pnpm run --filter react-on-rails-pro-node-renderer build`) - [x] Verified all 11 call sites — no caller changes required 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> * **Bug Fixes** * Improved rendering error messages to clearly show the request context, choosing a descriptive label when a JS rendering snippet is present or using a provided custom label/content. * Simplified the default label to "Request:" where applicable. * Trimmed and cleaned surrounding whitespace/newlines so error snippets and overall output are easier to read. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
#2877) - Renamed `renderingRequest` parameter to `requestDescription` in `formatExceptionMessage` - Changed the hardcoded label from `"JS code for rendering request was:"` to the neutral `"Request:"` - Updated JSDoc to reflect the broader usage Closes #2858 `formatExceptionMessage` was originally written for the render endpoint and hardcoded the label `"JS code for rendering request was:"`. Since the `/upload-assets` endpoint now also calls it (via lock-failure handling) with a task description string like `"Uploading bundles [server.js] with assets [stats.json]"`, this produced misleading error logs. The fix uses a generic label that works for both use cases. All 11 call sites already pass a `string`, so no caller changes were needed. - [x] TypeScript type-check passes (`pnpm run --filter react-on-rails-pro-node-renderer type-check`) - [x] ESLint passes on the changed file - [x] Package builds successfully (`pnpm run --filter react-on-rails-pro-node-renderer build`) - [x] Verified all 11 call sites — no caller changes required 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> * **Bug Fixes** * Improved rendering error messages to clearly show the request context, choosing a descriptive label when a JS rendering snippet is present or using a provided custom label/content. * Simplified the default label to "Request:" where applicable. * Trimmed and cleaned surrounding whitespace/newlines so error snippets and overall output are easier to read. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
…ages * origin/main: (44 commits) Consolidate CSP nonce sanitization into shared module (#2828) Add comprehensive --rsc-pro generator tests (#3098) fix: cross-env validation and docs for renderer password (#3090) Improve package metadata and Pro upgrade CTAs (#3112) docs: standardize warning syntax to GFM alert format (#3115) docs: improve react-intl documentation for React Server Components (#3085) Fix generator CI SSR regression on main (#3110) Refocus GitHub README on docs navigation (#3113) Add manual dev environment testing checklist for coding agents (#3074) Bump version to 16.6.0 Update CHANGELOG.md for 16.6.0 (#3078) fix: node-renderer diagnostic improvements (#3086) fix: pin third-party npm deps in generator to prevent peer dep conflicts (#3083) chore(deps): bump lodash from 4.17.23 to 4.18.1 in the npm-security group across 1 directory (#2920) fix: refactor formatExceptionMessage to accept generic request context (#2877) Bump version to 16.6.0.rc.1 Update CHANGELOG.md for 16.6.0.rc.1 (#3079) Update CHANGELOG.md unreleased section (#3077) Fix Content-Length mismatch and null renderingRequest errors in node renderer (#3069) Improve memory debugging docs with simpler heap snapshot approach (#3072) ... # Conflicts: # docs/pro/home-pro.md # docs/pro/react-on-rails-pro.md # docs/sidebars.ts
Summary
renderingRequestparameter torequestDescriptioninformatExceptionMessage"JS code for rendering request was:"to the neutral"Request:"Closes #2858
Context
formatExceptionMessagewas originally written for the render endpoint and hardcoded the label"JS code for rendering request was:". Since the/upload-assetsendpoint now also calls it (via lock-failure handling) with a task description string like"Uploading bundles [server.js] with assets [stats.json]", this produced misleading error logs. The fix uses a generic label that works for both use cases.All 11 call sites already pass a
string, so no caller changes were needed.Test plan
pnpm run --filter react-on-rails-pro-node-renderer type-check)pnpm run --filter react-on-rails-pro-node-renderer build)🤖 Generated with Claude Code
Summary by CodeRabbit