feat: custom-sounds.delete endpoint#40532
Conversation
|
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 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (3)📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-05-06T12:21:44.083ZApplied to files:
🔇 Additional comments (1)
WalkthroughAdds a POST REST endpoint ChangesCustom Sounds Delete API
Sequence Diagram(s)sequenceDiagram
participant Client
participant Endpoint as POST /v1/custom-sounds.delete
participant Validator as isCustomSoundsDeleteProps
participant Helper as deleteCustomSound
participant File as RocketChatFileCustomSoundsInstance
participant DB as CustomSounds
participant Broadcast as notify.deleteCustomSound
Client->>Endpoint: POST {_id}
Endpoint->>Validator: validate body
Validator-->>Endpoint: validation result
Endpoint->>Helper: deleteCustomSound(_id)
Helper->>DB: fetch sound by _id
DB-->>Helper: sound data / not found
Helper->>File: deleteFile({_id}.{ext})
Helper->>DB: removeById(_id)
Helper->>Broadcast: notify.deleteCustomSound(soundData)
Helper-->>Endpoint: complete
Endpoint-->>Client: 200 success / API.v1.failure on error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
🦋 Changeset detectedLatest commit: 6682158 The changes in this PR will be included in the next version bump. This PR includes changesets to release 42 packages
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40532 +/- ##
===========================================
- Coverage 69.65% 69.61% -0.05%
===========================================
Files 3324 3328 +4
Lines 122657 122869 +212
Branches 21882 21919 +37
===========================================
+ Hits 85439 85533 +94
- Misses 33884 33988 +104
- Partials 3334 3348 +14
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.
1 issue found across 7 files
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Re-trigger cubic
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 `@apps/meteor/tests/end-to-end/api/custom-sounds.ts`:
- Around line 425-431: The test case description "should return a 404 (Not
Found) if attempting to delete a sound that does not exist" is inconsistent with
the asserted status expect(400); update the test so description and assertion
match—either change the it(...) title to state 400 or change .expect(400) to
.expect(404); locate the test around the call to
request.post(api('custom-sounds.delete')) and make the title and the
.expect(...) value consistent (prefer changing the title to "should return a 400
(Bad Request)..." if the API actually returns 400).
🪄 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: 4383322b-142c-4dac-a49b-481e49a7d5e8
📒 Files selected for processing (1)
apps/meteor/tests/end-to-end/api/custom-sounds.ts
📜 Review details
🧰 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:
apps/meteor/tests/end-to-end/api/custom-sounds.ts
🧠 Learnings (3)
📚 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:
apps/meteor/tests/end-to-end/api/custom-sounds.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:
apps/meteor/tests/end-to-end/api/custom-sounds.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:
apps/meteor/tests/end-to-end/api/custom-sounds.ts
🔇 Additional comments (2)
apps/meteor/tests/end-to-end/api/custom-sounds.ts (2)
32-34: LGTM!
407-424: LGTM!Also applies to: 437-478
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 `@apps/meteor/app/api/server/v1/custom-sounds.ts`:
- Around line 313-319: The catch currently maps all exceptions from
deleteCustomSound(_id) to a client 4xx failure; change it to only translate
expected domain errors (e.g., not-found or validation errors) into
API.v1.failure with their message, and for any other unexpected errors log them
via SystemLogger.error({ error }) and return or rethrow a 5xx response (e.g.,
API.v1.failure('Internal Server Error', 500) or rethrow the error) so
infrastructure/file-store/db failures produce a 5xx; adjust the catch to inspect
the error type/code (or instanceof specific domain error classes) before
deciding between API.v1.failure(error.message) and API.v1.failure('Internal
Server Error', 500), keeping references to deleteCustomSound,
SystemLogger.error, and API.v1.failure.
🪄 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: 47bcca2d-1e41-4483-9ff3-ad2c47eacc97
📒 Files selected for processing (2)
apps/meteor/app/api/server/v1/custom-sounds.tsapps/meteor/tests/end-to-end/api/custom-sounds.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/meteor/tests/end-to-end/api/custom-sounds.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- 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:
apps/meteor/app/api/server/v1/custom-sounds.ts
🧠 Learnings (5)
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.
Applied to files:
apps/meteor/app/api/server/v1/custom-sounds.ts
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.
Applied to files:
apps/meteor/app/api/server/v1/custom-sounds.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 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:
apps/meteor/app/api/server/v1/custom-sounds.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:
apps/meteor/app/api/server/v1/custom-sounds.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:
apps/meteor/app/api/server/v1/custom-sounds.ts
| try { | ||
| await deleteCustomSound(_id); | ||
|
|
||
| return API.v1.success({}); | ||
| } catch (error: any) { | ||
| SystemLogger.error({ error }); | ||
| return API.v1.failure(error instanceof Error ? error.message : 'Unknown error'); |
There was a problem hiding this comment.
Preserve 5xx for unexpected delete failures.
This catch turns every exception from deleteCustomSound(_id) into a client-error response, so file-store or database failures during deletion look like request problems even when the input is valid. Please only translate expected domain errors here and rethrow/return a 5xx for unexpected failures.
🤖 Prompt for 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.
In `@apps/meteor/app/api/server/v1/custom-sounds.ts` around lines 313 - 319, The
catch currently maps all exceptions from deleteCustomSound(_id) to a client 4xx
failure; change it to only translate expected domain errors (e.g., not-found or
validation errors) into API.v1.failure with their message, and for any other
unexpected errors log them via SystemLogger.error({ error }) and return or
rethrow a 5xx response (e.g., API.v1.failure('Internal Server Error', 500) or
rethrow the error) so infrastructure/file-store/db failures produce a 5xx;
adjust the catch to inspect the error type/code (or instanceof specific domain
error classes) before deciding between API.v1.failure(error.message) and
API.v1.failure('Internal Server Error', 500), keeping references to
deleteCustomSound, SystemLogger.error, and API.v1.failure.
Proposed changes (including videos or screenshots)
Note: This PR is a cleaner final draft of #39828 (closed), that was messed up with different commits.
libfile.custom-sounds.deleteendpoint that uses the extracted method with validation schemas for responses and payloads.deleteCustomSoundMeteor method.Issue(s)
CORE-1971 Create
custom-sounds.deleteendpoint and deprecate its Meteor methodSteps to test or reproduce
We can test this change by accessing the custom sounds admin panel from the workspace and creating sounds to after delete them. Besides, we could test this using any API client and sending request directly to the server. We need to make sure that the user has the
manage-soundspermission.Further comments
Summary by CodeRabbit
New Features
Refactor
Types
Tests
Chores