Skip to content

Comments

refactor: update action collection body handling in API and services#41573

Open
sebastianiv21 wants to merge 2 commits intoreleasefrom
fix/jsobject-config-execution
Open

refactor: update action collection body handling in API and services#41573
sebastianiv21 wants to merge 2 commits intoreleasefrom
fix/jsobject-config-execution

Conversation

@sebastianiv21
Copy link
Contributor

@sebastianiv21 sebastianiv21 commented Feb 23, 2026

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.

  • 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.

Fixes #Issue Number
or
Fixes Issue URL

Warning

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.All
Spec:


Mon, 23 Feb 2026 21:32:46 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • More reliable action collection body updates with consistent merging of server responses and preserved local flags.
    • Fixed state handling to avoid unintended local mutations during save.
  • Improvements

    • API now returns full action collection details after updates, improving data accuracy and visibility.
    • Update flow now returns the populated, permission-aware collection so the client receives the updated view.

- 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.
@sebastianiv21 sebastianiv21 added the ok-to-test Required label for CI label Feb 23, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Walkthrough

The 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

Cohort / File(s) Summary
Frontend saga
app/client/src/sagas/JSPaneSagas.ts
Removed direct mutation of jsCollection.body; send updated body via action payload; on success merge server ActionCollectionDTO with local isMainJSCollection and dispatch updateJSCollectionBodySuccess.
Controller
app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.java
Changed updateActionCollectionBody return type from Mono<ResponseDTO<Integer>> to Mono<ResponseDTO<ActionCollectionDTO>>.
Service API (interface)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.java
Changed updateUnpublishedActionCollectionBody return type from Mono<Integer> to Mono<ActionCollectionDTO>.
Service implementation
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java
Updated implementation to return the updated ActionCollectionDTO: after update by ID, fetch the updated collection, resolve permissions, generate and populate view-model (generateActionCollectionByViewMode / populateActionCollectionByViewMode) before returning.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

✨ The payload flies to server-side,
A fuller DTO now rides the tide,
Frontend keeps its local flag,
Merges data—no more ragged patch,
Harmony restored, both ends allied.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description lacks critical information required by the template, including a specific issue reference and motivation context. Replace placeholder 'Fixes #Issue Number' with an actual issue link, add motivation/context for the type safety changes, and clarify dependencies if any exist.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring change: updating the return types and handling of action collection body updates across the API controller and service layers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/jsobject-config-execution

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/client/src/sagas/JSPaneSagas.ts (1)

675-687: Guard against missing response.data before object spread.

If response.data is null/undefined, {...serverData} throws and the saga fails despite a “successful” response. Add a fallback to the existing jsCollection.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 55ac824 and c14f7a3.

📒 Files selected for processing (4)
  • app/client/src/sagas/JSPaneSagas.ts
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java

- 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.
@sebastianiv21
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/22323305868.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 41573.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-41573.dp.appsmith.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant