refactor: update action collection body handling in API and services#41573
refactor: update action collection body handling in API and services#41573sebastianiv21 wants to merge 2 commits intoreleasefrom
Conversation
- Changed the return type of `updateActionCollectionBody` in `ActionCollectionControllerCE` to return `Mono<ResponseDTO<ActionCollectionDTO>>` instead of `Mono<ResponseDTO<Integer>>`. - Updated `updateUnpublishedActionCollectionBody` method signature in `LayoutCollectionServiceCE` and its implementation to return `Mono<ActionCollectionDTO>`. - Refactored the handling of the action collection body update to ensure the correct data is returned and processed. This refactor improves type safety and ensures that the updated action collection data is correctly handled across the application.
WalkthroughThe API endpoint for updating action collection bodies now returns the full updated ActionCollectionDTO instead of an Integer; backend service flow fetches and converts the updated collection before returning. Frontend saga stops mutating local collection, sends the new body in the request, and merges the server DTO with local flags on success. Changes
Sequence DiagramsequenceDiagram
participant Client as Frontend Saga
participant API as Server Controller
participant Service as Service Layer
participant DB as Database
Client->>API: PATCH /action-collection/{id} (body in payload)
API->>Service: updateUnpublishedActionCollectionBody(id, dto)
Service->>DB: Update collection body
Service->>DB: Fetch updated collection by ID
Service->>Service: resolve permissions / generate & populate view-model
Service-->>API: Return ActionCollectionDTO
API-->>Client: ResponseDTO<ActionCollectionDTO>
Client->>Client: Merge server DTO with local isMainJSCollection
Client->>Client: Dispatch updateJSCollectionBodySuccess
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/client/src/sagas/JSPaneSagas.ts (1)
675-687: Guard against missingresponse.databefore object spread.If
response.datais null/undefined,{...serverData}throws and the saga fails despite a “successful” response. Add a fallback to the existingjsCollection.Proposed fix
- const serverData = response.data; - const updatedJSCollection: JSCollection = { - ...serverData, + const serverData = response.data ?? jsCollection; + const updatedJSCollection: JSCollection = { + ...serverData, isMainJSCollection: !!jsCollection.isMainJSCollection, };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/client/src/sagas/JSPaneSagas.ts` around lines 675 - 687, The saga assumes response.data exists and spreads it into updatedJSCollection, which will throw if response.data is null/undefined; update the success branch in the generator (the code around JSActionAPI.updateJSCollectionBody / validateResponse) to use a safe fallback (e.g., const serverData = response.data || jsCollection) before creating updatedJSCollection so you spread a defined object and retain existing jsCollection fields when the server returns no data.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java`:
- Around line 303-308: The returned ActionCollectionDTO from
LayoutCollectionServiceCEImpl's update flow currently loses userPermissions;
after updateByIdWithoutPermissionCheck and after you generate/populate the DTO
via actionCollectionService.findById -> generateActionCollectionByViewMode ->
populateActionCollectionByViewMode, call
actionCollectionRepository.setUserPermissionsInObject(dbActionCollection.getId(),
dto) (or the repository method that enriches the DTO with userPermissions) to
set userPermissions into the ActionCollectionDTO before returning it so the
client retains permission info.
---
Nitpick comments:
In `@app/client/src/sagas/JSPaneSagas.ts`:
- Around line 675-687: The saga assumes response.data exists and spreads it into
updatedJSCollection, which will throw if response.data is null/undefined; update
the success branch in the generator (the code around
JSActionAPI.updateJSCollectionBody / validateResponse) to use a safe fallback
(e.g., const serverData = response.data || jsCollection) before creating
updatedJSCollection so you spread a defined object and retain existing
jsCollection fields when the server returns no data.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/client/src/sagas/JSPaneSagas.tsapp/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.javaapp/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.javaapp/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java
...mith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java
Show resolved
Hide resolved
- Added a new step in the action collection update process to set user permissions in the updated object. - This change ensures that user permissions are correctly applied after an action collection is updated, improving the overall integrity of permission management. This enhancement contributes to a more robust and secure handling of user permissions within the application.
|
/build-deploy-preview skip-tests=true |
|
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/22323305868. |
|
Deploy-Preview-URL: https://ce-41573.dp.appsmith.com |
Description
Tip
Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).
Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.
updateActionCollectionBodyinActionCollectionControllerCEto returnMono<ResponseDTO<ActionCollectionDTO>>instead ofMono<ResponseDTO<Integer>>.updateUnpublishedActionCollectionBodymethod signature inLayoutCollectionServiceCEand its implementation to returnMono<ActionCollectionDTO>.This refactor improves type safety and ensures that the updated action collection data is correctly handled across the application.
Fixes #
Issue Numberor
Fixes
Issue URLWarning
If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.
Automation
/ok-to-test tags="@tag.All"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/22323250400
Commit: f94f109
Cypress dashboard.
Tags:
@tag.AllSpec:
Mon, 23 Feb 2026 21:32:46 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Bug Fixes
Improvements