Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removed non reactive json migration #36413

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Sep 19, 2024

Description

There were multiple ways to migrate an ArtifactExchangeJson, Some flows couldn't be used on non reactive code because of db calls, hence unified the migration logic to be only reactive.

Fixes #36414

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.ImportExport, @tag.Git, @tag.Fork"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10957926625
Commit: 612bb7b
Cypress dashboard.
Tags: @tag.ImportExport, @tag.Git, @tag.Fork
Spec:


Fri, 20 Sep 2024 11:15:03 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced enhanced migration capabilities for application JSON artifacts, accommodating both branched and non-branched data.
    • Added asynchronous processing for improved performance during application JSON migration.
  • Bug Fixes

    • Improved error handling and logging during the artifact import process.
  • Refactor

    • Streamlined the artifact import and migration processes using reactive programming principles for better clarity and maintainability.
    • Simplified the creation and handling of application JSON objects within the import process.
  • Tests

    • Updated tests to reflect changes in migration methods and ensure proper functionality with the new reactive approach.

@sondermanish sondermanish requested review from sharat87, abhvsn and a team as code owners September 19, 2024 07:39
@sondermanish sondermanish self-assigned this Sep 19, 2024
Copy link
Contributor

coderabbitai bot commented Sep 19, 2024

Walkthrough

The changes in this pull request introduce enhancements to the application import service, specifically focusing on the migration of application JSON artifacts to the latest schema. A new method for migrating artifacts has been added, along with modifications to existing methods and classes to support this functionality. The changes promote a reactive programming model, improving the clarity and maintainability of the code while ensuring compatibility with the latest schema requirements.

Changes

File Change Summary
.../ApplicationImportServiceCEImpl.java Added a method migrateArtifactExchangeJson for migrating application JSON artifacts, integrating a new dependency JsonSchemaMigration.
.../ApplicationImportServiceImpl.java Updated the constructor to include JsonSchemaMigration, enhancing the service's capability to support JSON schema migrations.
.../ImportServiceCEImpl.java Refactored the importArtifactInWorkspace method to streamline schema migration and validation using reactive programming principles, improving error handling and maintainability.
.../ArtifactBasedImportServiceCE.java Introduced a new method signature migrateArtifactExchangeJson to the interface for handling artifact migration in a branched context.
.../JsonSchemaMigration.java Enhanced the migration logic by updating migrateArtifactExchangeJsonToLatestSchema to accept baseArtifactId and branchName, refactoring the internal migration process for better readability and reactive handling.
.../CreateDBTablePageSolutionCEImpl.java Improved the createPageFromDBTable method to utilize a Mono<ApplicationJson> for asynchronous operations, enhancing performance and code clarity.
.../CommonGitServiceCETest.java Updated the createAppJson method to use flatMap for migration, enhancing flexibility in handling application JSON artifacts.
.../GitFileUtilsTest.java Modified the createAppJson method to replace the previous migration method with a flatMap operation, indicating a shift to more complex and asynchronous processing.
.../ImportServiceTests.java Adjusted the createAppJson method to utilize flatMap for migration, improving the handling of application JSON artifacts and enhancing maintainability.
.../JsonSchemaMigrationTest.java Updated test cases to reflect changes in the migration method signature, adapting to the new parameters while maintaining expected outcomes.
.../ImportApplicationTransactionServiceTest.java Changed the migration method call to a more specific one, indicating a tailored approach to JSON schema migration with asynchronous processing.

Assessment against linked issues

Objective Addressed Explanation
Remove non-reactive JSON migration and implement a reactive migration strategy (36414)

Possibly related PRs

Suggested labels

Backend, ok-to-test

🎉 In the realm of code, where changes take flight,
New methods emerge, shining so bright.
Migrations now dance, in a reactive flow,
Clarity and structure, watch the improvements grow!
With each line refined, we celebrate this feat,
Cheers to the changes, making our work sweet! 🎊


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 52034ec and 612bb7b.

Files selected for processing (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java
Additional context used
Learnings (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (1)
Learnt from: sondermanish
PR: appsmithorg/appsmith#36413
File: app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java:514-518
Timestamp: 2024-09-20T07:55:30.235Z
Learning: In the `ImportServiceCEImpl` class, when throwing new `AppsmithException` instances, avoid adding the original `Throwable` as the cause due to messaging constraints.
Additional comments not posted (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (1)

414-438: Great work on refactoring the schema migration and validation logic! 👍

The changes made to the importArtifactInWorkspace method significantly improve the clarity and error handling of the artifact import process. By encapsulating the schema migration within a Mono and using flatMap to execute the validation logic, you've ensured that validation occurs only after a successful migration. This prevents unnecessary validation attempts on invalid or incomplete data.

Furthermore, the validation logic now provides more informative error messages by checking for specific missing fields and logging appropriate error details. This enhances the debugging experience and helps identify the root cause of validation failures more quickly.

Moving the synchronization of client and schema versions to occur after the validation step is also a logical improvement, as it ensures that the versions are synced only for valid artifacts.

Overall, these changes enhance the robustness and maintainability of the artifact import process. Keep up the excellent work!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Sep 19, 2024
@sondermanish sondermanish changed the title chore: Chore/reactive json migration chore: removed non reactive json migration Sep 19, 2024
@github-actions github-actions bot added the Task A simple Todo label Sep 19, 2024
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: 6

Outside diff range and nitpick comments (4)
app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java (2)

Line range hint 93-112: Consider updating the method call for consistency.

Class, while reviewing this test, I noticed that the migrateApplicationJsonToLatestSchema method call hasn't been updated to include the two null parameters, unlike the previous tests for migrateArtifactExchangeJsonToLatestSchema.

To maintain consistency across the test suite, I recommend updating the method call to include these parameters:

Mono<ApplicationJson> applicationJsonMono =
        jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null);

This will ensure that all tests are aligned with the new method signatures.


Line range hint 114-135: Update the method call to match the new signature.

Class, I have one more observation regarding consistency. Similar to the previous test, the migrateApplicationJsonToLatestSchema method call in this test hasn't been updated to include the two null parameters.

To maintain uniformity across all tests, please update the method call as follows:

Mono<ApplicationJson> applicationJsonMono =
        jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null);

Consistency in test structure and method usage is key to ensuring the overall maintainability and readability of the test suite.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java (1)

294-296: Good work! The method logic is sound.

Just one small suggestion:
Consider handling exceptions that may occur while reading the file or migrating the schema. Returning an error Mono in the catch block will make the code more robust.

app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (1)

Line range hint 85-161: Consider Refactoring the Migration Logic for Better Maintainability

Dear class, the extensive switch-case block within the migrateServerSchema method (lines 85-161) is becoming quite lengthy and may affect readability. Refactoring each case into separate methods can make the code cleaner and easier to maintain. Breaking down complex methods is a good practice that enhances the understandability of our code.

Here's how you might refactor the method:

private Mono<ApplicationJson> migrateServerSchema(ApplicationJson applicationJson, String baseApplicationId, String branchName) {
    if (jsonSchemaVersions.getServerVersion().equals(applicationJson.getServerSchemaVersion())) {
        return Mono.just(applicationJson);
    }

    switch (applicationJson.getServerSchemaVersion()) {
        case 0:
            return migrateFromVersion0(applicationJson)
                    .flatMap(updatedJson -> migrateServerSchema(updatedJson, baseApplicationId, branchName));
        // Include cases for each version
        default:
            return Mono.just(applicationJson);
    }
}

private Mono<ApplicationJson> migrateFromVersion0(ApplicationJson applicationJson) {
    // Migration logic for version 0 to 1
    applicationJson.setServerSchemaVersion(1);
    return Mono.just(applicationJson);
}

// Similarly, create methods for other versions

This approach modularizes each migration step, making it clearer and easier to manage future changes.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 006dbfd and 52034ec.

Files selected for processing (11)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java (4 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/ImportServiceCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/artifactbased/ArtifactBasedImportServiceCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/CreateDBTablePageSolutionCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitFileUtilsTest.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java (2 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java (2 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/transactions/ImportApplicationTransactionServiceTest.java (1 hunks)
Additional comments not posted (11)
app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java (2)

15-15: Good job adding the import statement for JsonSchemaMigration!

The import statement looks correct and indicates that the JsonSchemaMigration class will be utilized in this file. Keep up the great work!


39-39: Excellent work adding the JsonSchemaMigration parameter to the constructor!

The addition of the JsonSchemaMigration parameter and passing it to the super constructor looks great. This change suggests that the ApplicationImportServiceImpl class now requires an instance of JsonSchemaMigration for its functionality.

However, let's make sure to verify the usage of ApplicationImportServiceImpl across the codebase to ensure that the new parameter is properly provided during instantiation. We can use the following script to check for any potential issues:

Keep up the fantastic work, and let's ensure a smooth integration of this change!

Also applies to: 55-55

Verification successful

Alright, class! It seems our previous search didn't yield the results we expected. Let's approach this problem step by step and see if we can find where our ApplicationImportServiceImpl is hiding. Remember, in programming, as in life, persistence is key!

Now, let's run these commands and see what we can learn about our elusive ApplicationImportServiceImpl. Pay attention, class, as this is how we debug and investigate in the real world!


Excellent work, class! We've made some progress in our investigation. Let's review our findings and determine our next steps.

We've successfully located our ApplicationImportServiceImpl class. It's right where we expected it to be, extending the ApplicationImportServiceCEImpl class. However, we still need to verify a few things to ensure our code change is properly integrated.

Let's focus on three key areas:

  1. The constructor parameters
  2. Usage of this class in other parts of the codebase
  3. The apparent lack of test coverage

Here's what we'll do next:

Now, let's run these commands and see what we can learn. Remember, class, thorough investigation is key to maintaining a robust codebase!


Alright, class, let's review what we've learned from our investigation!

Good news: The constructor change looks spot-on!

We can see that the JsonSchemaMigration parameter has been added to the ApplicationImportServiceImpl constructor, just as we discussed in our previous lesson. This shows excellent attention to detail!

However, we've uncovered a few areas that require our attention:

  1. We couldn't find any direct usage of ApplicationImportServiceImpl outside its own file. This isn't necessarily a problem, as it might be used through dependency injection. But it's something to keep in mind.

  2. More importantly, we couldn't find any test files specifically related to ApplicationImport. This is a bit concerning, as it might indicate a gap in our test coverage.

So, what's our homework assignment?

  1. First and foremost, pat yourself on the back for implementing the constructor change correctly!

  2. Next, let's focus on improving our test coverage. It would be a good idea to create or update test cases for ApplicationImportServiceImpl to ensure its functionality is properly verified.

  3. Lastly, I recommend a manual review of the dependency injection configuration. This will help us confirm that ApplicationImportServiceImpl is being used correctly throughout the application.

Remember, class, thorough testing and proper dependency management are crucial for maintaining a robust and reliable codebase!

Does anyone have any questions about our findings or the next steps?

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ApplicationImportServiceImpl` across the codebase.

# Test: Search for the constructor usage. Expect: Occurrences with the new `JsonSchemaMigration` parameter.
rg --type java -A 5 $'new ApplicationImportServiceImpl'

Length of output: 56


Script:

#!/bin/bash
# Description: Investigate ApplicationImportServiceImpl usage and definition

# Search for the class definition
echo "Searching for ApplicationImportServiceImpl class definition:"
rg --type java "class ApplicationImportServiceImpl"

# Search for any mention of ApplicationImportServiceImpl
echo -e "\nSearching for any mention of ApplicationImportServiceImpl:"
rg --type java "ApplicationImportServiceImpl"

# Search for possible bean definitions in Spring configuration files
echo -e "\nSearching for possible bean definitions:"
rg --type xml --type java "ApplicationImportService"

# Search for possible usage in test files
echo -e "\nSearching for usage in test files:"
rg --type java "ApplicationImportService.*Test"

Length of output: 1715


Script:

#!/bin/bash
# Description: Further investigation of ApplicationImportServiceImpl

# Check the constructor parameters
echo "Checking ApplicationImportServiceImpl constructor:"
rg --type java -A 10 "public ApplicationImportServiceImpl\(" app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceImpl.java

# Look for usage of ApplicationImportServiceImpl
echo -e "\nSearching for usage of ApplicationImportServiceImpl:"
rg --type java "ApplicationImportServiceImpl" --glob !**/ApplicationImportServiceImpl.java

# Search for test files related to application import
echo -e "\nSearching for related test files:"
rg --type java "class.*Test.*ApplicationImport"

Length of output: 1195

app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/artifactbased/ArtifactBasedImportServiceCE.java (1)

157-157: Excellent work on expanding the interface's capabilities! 👏

The new migrateArtifactExchangeJson method is a valuable addition to the ArtifactBasedImportServiceCE interface. It introduces a dedicated operation for migrating artifact exchange data in the context of a branched artifact.

By accepting a branchedArtifactId and an ArtifactExchangeJson object as parameters, this method enables more targeted and specific migration scenarios. The reactive return type Mono<V> indicates that the method will perform its operations asynchronously, which is a good practice for potentially time-consuming tasks like data migration.

This addition enhances the flexibility and functionality of the interface without disrupting existing methods. It opens up new possibilities for handling artifact exchange data migration in branched contexts.

Keep up the great work in improving the artifact management capabilities of the system! 🌟

app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java (2)

58-60: Good work updating the test to match the new method signature!

Class, I see that you've updated the migrateArtifactExchangeJsonToLatestSchema method call to include two additional null parameters. This aligns with the changes made to the method signature.

However, as a friendly reminder, it would be beneficial to consider adding tests in the future to cover scenarios where these new parameters are not null. This will help ensure the robustness of the migration logic.

Keep up the great work!


82-84: Excellent job maintaining consistency in the test updates!

Class, I noticed that you've made similar changes to this test as you did in the previous one. You've updated the migrateArtifactExchangeJsonToLatestSchema method call to include the two null parameters, which is consistent with the new method signature.

Maintaining consistency in test updates is crucial for ensuring the overall reliability and maintainability of the test suite. Well done!

app/server/appsmith-server/src/test/java/com/appsmith/server/transactions/ImportApplicationTransactionServiceTest.java (1)

133-134: Great work on improving the migration logic! 👍

The changes made to the createAppJson method align perfectly with the PR objective of unifying the migration logic for ArtifactExchangeJson in a reactive manner. By replacing the generic migrateArtifactToLatestSchema method with the more specific migrateArtifactExchangeJsonToLatestSchema, you've ensured that the migration process is tailored to handle this particular artifact type effectively.

Moreover, the switch from map to flatMap, along with the Mono return type of the new migration method, enables reactive processing. This addresses the previous issue of certain migration flows not being usable in non-reactive code due to database calls.

Overall, these changes enhance the functionality, reliability, and consistency of the migration process for ArtifactExchangeJson. Well done! 🌟

app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/GitFileUtilsTest.java (1)

87-88: Great work on enhancing the migration process! 🎉

I see you've introduced a flatMap operation to handle the schema migration asynchronously. This looks like a step in the right direction to make the migration more flexible. 👍

Just one thing to double-check:

I noticed you're passing null as the second and third arguments to migrateArtifactExchangeJsonToLatestSchema. Let's make sure this won't cause any unintended issues down the line. Could you please verify the impact of passing null parameters and confirm it's safe? 🔍

Here's a script to help track down any potential problems:

If everything checks out, then we're good to go! Let me know if you have any questions. 😊

Verification successful

Alright, class! Let's continue our investigation into the migrateArtifactExchangeJsonToLatestSchema method. Our previous attempt gave us some valuable insights, but we need to dig a little deeper. Let's run a few more tests to make sure we fully understand how those null parameters are being handled. Here's what we're going to do next:

Now, let's run these tests and see what we can learn about how our method handles those null parameters. Pay attention, class! The results will help us understand if our code is being a good student or if it needs some extra tutoring.


Alright, class! Let's review what we've learned about our migrateArtifactExchangeJsonToLatestSchema method. Pay attention, because this is important!

Good news! The use of null parameters is intentional and well-documented. 📚✅

Here's what we've discovered:

  1. The method's documentation explicitly states that null values are expected for baseArtifactId and branchName in certain cases. This is like having a clear set of instructions for our homework!

  2. Our test cases consistently use null values for these parameters, showing that this is the intended design. It's like everyone in class following the same formula!

  3. The method seems to handle these null values gracefully, just like how we handle unexpected questions during a pop quiz.

However, to make our code even more robust, we could suggest a small improvement:

  • Consider adding explicit null checks for baseArtifactId and branchName at the beginning of the method, if they're not already present. This would be like double-checking your work before handing in your assignment!

Remember, class, it's always good to be extra careful, even when we're following the rules!

Any questions? Don't be shy, raise your hand if you need clarification! 🙋‍♂️🙋‍♀️

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of passing null parameters to migrateArtifactExchangeJsonToLatestSchema.

# Test 1: Search for migrateArtifactExchangeJsonToLatestSchema usages. 
# Expect: Understand how the method handles null parameters.
rg --type java -A 5 $'migrateArtifactExchangeJsonToLatestSchema'

# Test 2: Search for potential null pointer dereferences. 
# Expect: No occurrences of dereferencing the 2nd or 3rd parameter without a null check.
ast-grep --lang java --pattern $'migrateArtifactExchangeJsonToLatestSchema($_, $secondParam, $thirdParam) {
  $$$
  $secondParam.$_
  $$$
}'

ast-grep --lang java --pattern $'migrateArtifactExchangeJsonToLatestSchema($_, $secondParam, $thirdParam) {
  $$$
  $thirdParam.$_
  $$$
}'

Length of output: 9129


Script:

#!/bin/bash
# Description: Further investigation of migrateArtifactExchangeJsonToLatestSchema method

# Test 1: Search for null checks within the method
rg --type java -A 10 -B 5 'migrateArtifactExchangeJsonToLatestSchema.*\{' | rg '(baseArtifactId|branchName)\s*[!=]=\s*null'

# Test 2: Look for comments or documentation related to the method
rg --type java -A 5 -B 10 'migrateArtifactExchangeJsonToLatestSchema'

# Test 3: Correct ast-grep command to search for potential null pointer dereferences
ast-grep --lang java 'migrateArtifactExchangeJsonToLatestSchema($_, $secondParam, $thirdParam)'

# Test 4: Search for usage of baseArtifactId and branchName within the method
rg --type java -A 20 -B 5 'migrateArtifactExchangeJsonToLatestSchema.*\{' | rg '(baseArtifactId|branchName)'

Length of output: 20060

app/server/appsmith-server/src/main/java/com/appsmith/server/applications/imports/ApplicationImportServiceCEImpl.java (1)

645-666: Excellent work on implementing the artifact exchange JSON migration logic! 👏

The migrateArtifactExchangeJson method is well-structured and handles the migration process effectively. It takes into account the presence or absence of the branchedArtifactId and retrieves the necessary details like base artifact ID and branch name accordingly. The method invokes the jsonSchemaMigration.migrateApplicationJsonToLatestSchema method with the appropriate parameters to perform the actual migration.

The asynchronous nature of the method, returning a Mono<ApplicationJson>, aligns with the reactive programming paradigm and ensures efficient processing.

Keep up the great work! Your implementation is clear, concise, and follows best practices. 🌟

app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java (2)

360-361: Great work on updating the migration function! 👍

The changes to use migrateArtifactExchangeJsonToLatestSchema with additional null parameters allow for a more adaptable migration process. This sets the stage for handling future enhancements or variations in the migration logic. Well done!


2722-2728: Excellent update to the migration logic! 🌟

By utilizing a flat mapping approach and copying nested non-null properties to a new instance before applying the migration, you've enhanced the migration process to handle complex data structures more effectively. The use of flatMap also suggests the potential for asynchronous operations, which can further optimize the migration. Keep up the great work!

app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (1)

49-53: Ensure All Method Calls Are Updated With New Parameters

Students, when we modify a method's signature by adding new parameters, it's crucial to update all calls to this method throughout the codebase. The method migrateArtifactExchangeJsonToLatestSchema now includes baseArtifactId and branchName as parameters. Let's verify that all usages are updated accordingly to prevent any compilation errors or unexpected behavior.

Run the following script to identify any outdated method calls:

This will help us locate any instances where the method is called without the new parameters so we can update them.

Verification successful

Class, it seems our previous attempt to search for the method calls didn't quite make the grade. Let's try a different approach using a tool better suited for understanding code structure. We'll use ast-grep to find all calls to our method of interest.

This new search should give us a more comprehensive view of how our method is being called throughout the codebase. Once we have the results, we can examine them to ensure all calls include the new parameters.


Alright, class, it seems our previous approach didn't yield the results we were hoping for. Let's try a simpler method, shall we? Sometimes, the most straightforward approach is the most effective. We'll use a basic text search to find any mentions of our method.

This command will search for any occurrence of our method name in Java files and show us 3 lines of context before and after each match. This should give us a clear picture of how and where the method is being used. Remember, in programming as in life, persistence and adaptability are key!


Excellent work, class! After our thorough investigation, I'm pleased to report that we've made some important discoveries. Let's review our findings together.

All Method Calls Successfully Updated

Our code archaeology has revealed that all instances of migrateArtifactExchangeJsonToLatestSchema have been properly updated to include the new parameters. Here's what we've learned:

  1. The main implementation in JsonSchemaMigration.java correctly includes the new parameters baseArtifactId and branchName.
  2. All test files have adapted their method calls to include these new parameters, albeit using null values.

While the use of null in tests is acceptable, it presents an opportunity for improvement. Consider this your homework assignment:

  • Review your test cases and, where appropriate, include tests with non-null values for baseArtifactId and branchName. This will ensure more comprehensive coverage of the new functionality.

Remember, thorough testing is the foundation of robust software. Keep up the good work, and don't hesitate to ask questions if you need clarification on any part of this update.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of migrateArtifactExchangeJsonToLatestSchema without the new parameters.

rg --type java 'migrateArtifactExchangeJsonToLatestSchema\((?!ArtifactExchangeJson, String, String)'

Length of output: 432


Script:

#!/bin/bash
# Find all calls to migrateArtifactExchangeJsonToLatestSchema
ast-grep --lang java --pattern 'migrateArtifactExchangeJsonToLatestSchema($_)'

Length of output: 80


Script:

#!/bin/bash
# Simple text search for migrateArtifactExchangeJsonToLatestSchema
rg --type java "migrateArtifactExchangeJsonToLatestSchema" -C 3

Length of output: 8845

nidhi-nair
nidhi-nair previously approved these changes Sep 19, 2024
Copy link
Contributor

@nidhi-nair nidhi-nair left a comment

Choose a reason for hiding this comment

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

LGTM, please take a look at the CodeRabbit suggestions, some of them look like worth imbibing.

Copy link

Failed server tests

  • com.external.plugins.MssqlGetDBSchemaTest#
  • com.external.plugins.MssqlPluginTest#

1 similar comment
Copy link

Failed server tests

  • com.external.plugins.MssqlGetDBSchemaTest#
  • com.external.plugins.MssqlPluginTest#

@sondermanish sondermanish added the ok-to-test Required label for CI label Sep 20, 2024
Copy link

Failed server tests

  • com.external.plugins.MssqlGetDBSchemaTest#
  • com.external.plugins.MssqlPluginTest#

@nidhi-nair nidhi-nair merged commit 9bbf794 into release Sep 20, 2024
47 of 49 checks passed
@nidhi-nair nidhi-nair deleted the chore/reactive-json-migration branch September 20, 2024 12:12
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task: Remove non reactive json migration
2 participants