fix: send body in api client delete method - #41349
Conversation
🦋 Changeset detectedLatest commit: 2716824 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
Walkthrough
ChangesDELETE body fix
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
|
Caution Review failedAn error occurred during the review process. Please try again later. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/api-client/src/index.ts`:
- Around line 191-207: Update the DELETE request method to return an empty
result without calling response.json() when the response status is 204, matching
the existing POST behavior. Also apply Content-Type: application/json only when
params is defined and the request is not FormData, while preserving existing
headers for parameter-less requests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 47b4d86f-3351-4cc9-b811-fef610c57748
📒 Files selected for processing (2)
.changeset/fix-rest-client-delete-body.mdpackages/api-client/src/index.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
packages/api-client/src/index.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.
Applied to files:
.changeset/fix-rest-client-delete-body.md
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
packages/api-client/src/index.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
packages/api-client/src/index.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
packages/api-client/src/index.ts
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #41349 +/- ##
===========================================
- Coverage 68.38% 68.38% -0.01%
===========================================
Files 3970 3970
Lines 154935 154942 +7
Branches 27807 27833 +26
===========================================
- Hits 105960 105956 -4
- Misses 44232 44252 +20
+ Partials 4743 4734 -9
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Re-trigger cubic
Proposed changes (including videos or screenshots)
RestClient.delete(packages/api-client/src/index.ts:189) silently dropped itsparamsargument and never sent a request body. This PR makesdeleteforwardparamsas a JSON (or FormData) body — mirroring the existingpost/putbehavior — so DELETE endpoints that expect a body now work. Param-less DELETE calls are unchanged (no body is sent).Example
Affected APIs
DELETE /v1/push.tokenapps/meteor/server/api/v1/push.ts:63-79(PushTokenDELETE = { token: string }), route wired atapps/meteor/server/api/v1/push.ts:211{ token: string }in the request body. Previously the body was silently dropped, causingerror-token-param-not-valid.DELETE /v1/livechat/message/:_idpackages/ddp-client/src/livechat/LivechatClientImpl.ts:328-333(deleteMessage); typed atpackages/rest-typings/src/v1/omnichannel.ts:4921-4924(DELETELivechatMessageIdParams){ rid, token }in the request body. Previously discarded, now sent correctly.DELETE /v1/livechat/visitor/:tokenpackages/ddp-client/src/livechat/LivechatClientImpl.ts:335-339(deleteVisitor)No caller passed
paramsexpecting them as a query string, so this is a safe behavioral fix with no regressions.Issue(s)
https://rocketchat.atlassian.net/browse/CORE-2422
Steps to test or reproduce
sdk.rest.delete('/v1/push.token', { token: 'abc' })sent an empty DELETE (token dropped) → server 400error-token-param-not-valid.{ success: true }.LivechatClientImpl.deleteMessagenow deliversrid/tokento the server.Further comments
Note:
rest-typingsdoes not yet declareDELETE /v1/push.token, soParamsFor<'DELETE', '/v1/push.token'>currently resolves tovoid— callers must cast until that route is typed (intentionally left out of this PR to keep scope minimal).Summary by CodeRabbit
Bug Fixes
DELETErequests so provided parameters are included in the request body (matchingPOST/PUTbehavior).DELETE, including correct handling of JSON vs form-data.Tests
DELETEbody/headers behavior, multipart handling with files, and 204 (empty response) handling.Release