fix: non null check on published action (#40598)

## 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._


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
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14879842425>
> Commit: 7b958d423567766bc8531425e5cb045c45752567
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14879842425&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Wed, 07 May 2025 10:34:51 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved reliability during app import by preventing potential errors
when handling actions without published versions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com>
This commit is contained in:
Nilesh Sarupriya 2025-05-07 18:14:11 +05:30 committed by GitHub
parent c57cc56775
commit 64944a3a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,6 +64,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -408,14 +409,16 @@ public class PartialImportServiceCEImpl implements PartialImportServiceCE {
}
applicationJson.getActionList().forEach(action -> {
action.getPublishedAction().setPageId(pageName);
action.getUnpublishedAction().setPageId(pageName);
if (Objects.nonNull(action.getPublishedAction())) {
action.getPublishedAction().setPageId(pageName);
if (action.getPublishedAction().getCollectionId() != null) {
String collectionName =
action.getPublishedAction().getCollectionId().split("_")[1];
action.getPublishedAction().setCollectionId(pageName + "_" + collectionName);
action.getUnpublishedAction().setCollectionId(pageName + "_" + collectionName);
}
}
String actionName = action.getId().split("_")[1];
action.setId(pageName + "_" + actionName);