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

fix: added an autocommit migration for theme settings. #35554

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Aug 8, 2024

Description

Fixes #35536

Automation

/ok-to-test tags="@tag.Git"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10315694999
Commit: f03353b
Cypress dashboard.
Tags: @tag.Git
Spec:


Fri, 09 Aug 2024 08:16:04 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced migration logic for server schema versions, ensuring proper handling of theme settings during migrations from version 6 to 9.
    • Introduced methods to establish and set default theme settings for applications during migration.
  • Bug Fixes

    • Simplified server version retrieval process, ensuring consistent versioning behavior.
  • Tests

    • Updated tests to reflect changes in server version expectations, removing unnecessary assertions related to feature flags.
    • Streamlined validation logic in migration tests to focus solely on expected schema versions.

Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

The recent changes enhance the migration capabilities of the server schema within the application. New logic has been implemented to manage theme settings during migrations from schema version 6 to 9. Additionally, the version retrieval process has been simplified, improving clarity and robustness. Test adjustments ensure that these changes are accurately reflected in the testing framework. Overall, these updates aim to streamline the migration process and enhance application performance.

Changes

Files Change Summary
app/server/migrations/JsonSchemaMigration.java, app/server/migrations/MigrationHelperMethods.java Enhanced migration logic for theme settings, added new migration cases, and introduced new helper methods.
app/server/migrations/JsonSchemaVersions.java, app/server/migrations/JsonSchemaVersionsFallback.java Removed feature flag from version retrieval and updated server version to 9 for compatibility improvements.
app/server/test/migrations/JsonSchemaVersionsTest.java, app/server/test/migrations/JsonSchemaMigrationTest.java Simplified test assertions related to server version retrieval and migration logic under feature flag conditions.
app/server/test/imports/internal/ImportServiceTests.java Adjusted assertions to align with expected application states post-import, removing checks for null values.

Assessment against linked issues

Objective Addressed Explanation
Uncommitted changes are present in git-connected apps (#[35536])

In the realm of code where changes align,
Migration flows smoothly, now how divine!
Theme settings flourish, with logic refined,
A version update, simplicity entwined.
With tests now clearer, the pathway is bright,
Here’s to progress, coding’s pure delight! 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 Bug Something isn't working Needs Triaging Needs attention from maintainers to triage Production Release Blocker This issue must be resolved before the release labels Aug 8, 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: 0

Outside diff range, codebase verification and nitpick comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (1)

147-150: Ensure consistency in migration logic.

The addition of cases 7 and 8 for theme settings migration appears correct. However, ensure that any dependencies or prerequisites for these migrations are met before execution. Consider adding comments to clarify the purpose of these migrations.

+ // Migrate theme settings for schema versions 7 and 8
app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/MigrationHelperMethods.java (2)

1187-1218: Confirm initialization logic for theme settings.

The method correctly initializes ApplicationDetail and ThemeSetting objects if they are null. This ensures that theme settings are always present. Consider adding logging or comments to indicate when initialization occurs for better traceability.

+ // Initialize theme settings if not already present

1220-1233: Ensure default values are set correctly.

The method correctly assigns default values for appMaxWidth, density, and sizing. This ensures consistency in theme settings. Consider adding comments to explain the choice of default values for clarity.

+ // Set default values for theme settings
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 061e376 and a93268d.

Files selected for processing (5)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaVersions.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaVersionsFallback.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/MigrationHelperMethods.java (2 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaVersionsTest.java (1 hunks)
Additional comments not posted (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaVersions.java (1)

22-22: Simplified version retrieval logic.

The removal of the feature flag annotation and the direct return of super.getServerVersion() simplifies the method. Ensure that this change aligns with the intended behavior across the codebase.

Verification successful

Simplified version retrieval logic verified.

The removal of the feature flag annotation and the direct return of super.getServerVersion() does not appear to impact any conditional logic or feature flag-dependent behavior in the current codebase. The change aligns with the intended simplification of the method.

  • No conditional logic or feature flag dependencies: The search results did not reveal any conditional logic or feature flag dependencies directly related to getServerVersion.

This change is consistent with the overall design and should not affect other parts of the application.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing the feature flag annotation from `getServerVersion`.

# Test: Search for references to `getServerVersion` to ensure no conditional logic depends on the feature flag.
rg --type java 'getServerVersion'

Length of output: 9295


Script:

#!/bin/bash
# Description: Check for any feature flag or conditional logic related to `getServerVersion` in migration and test files.

# Check for feature flag usage in migration files
rg --type java 'feature flag' app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/

# Check for conditional logic related to `getServerVersion` in test files
rg --type java 'if.*getServerVersion' app/server/appsmith-server/src/test/

Length of output: 807

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

7-7: Server version incremented to 9.

The server version has been updated from 7 to 9, indicating changes in schema compatibility. Ensure that this increment is well-documented and aligns with the migration logic.

app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaVersionsTest.java (1)

53-53: Updated test assertion for server version.

The test now asserts that the server version equals the fallback version, aligning with the simplified version retrieval logic. Ensure that this reflects the intended behavior change and verify test coverage.

Verification successful

Test coverage for getServerVersion appears comprehensive.

The search results indicate that getServerVersion is tested in multiple contexts across different test files. This suggests that the test coverage for this method is indeed comprehensive and should reflect the intended behavior change. If there are specific scenarios or edge cases you are concerned about, you may want to review the individual test cases to ensure they align with the new logic.

  • Files with relevant tests:
    • JsonSchemaMigrationTest.java
    • JsonSchemaVersionsTest.java
    • CommonGitServiceCETest.java
    • AutoCommitServiceTest.java
    • ExportServiceTests.java
    • ImportServiceTests.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for server version retrieval logic.

# Test: Search for tests related to `getServerVersion` to ensure comprehensive coverage.
rg --type java 'getServerVersion'

Length of output: 9295

public Integer getServerVersion() {
return super.getServerVersion() + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will you be cleaning this up later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that is when we remove a secondary class with autocommit flags.

}

// since these are primitive values we don't have concept of null, hence putting it to the default of 1.
if (themeSetting.getDensity() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When would we arrive at this scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are not expected to land on this scenario by default, Even if we don't have the density and sizing values not present while deserialising we would start with 1, right? (if not then it's for that).

Copy link

github-actions bot commented Aug 8, 2024

Failed server tests

  • com.appsmith.server.imports.internal.ImportServiceTests#discardChange_addNavigationAndThemeSettingAfterImport_addedNavigationAndThemeSettingRemoved
  • com.appsmith.server.migrations.JsonSchemaMigrationTest#migrateApplicationJsonToLatestSchema_whenFeatureFlagIsOn_returnsIncrementedValue
  • com.appsmith.server.migrations.JsonSchemaMigrationTest#migrateArtifactToLatestSchema_whenFeatureFlagIsOn_returnsIncrementedValue
  • com.appsmith.server.services.ThemeServiceTest#publishTheme_WhenSystemThemeIsSet_NoNewThemeCreated

Copy link

github-actions bot commented Aug 8, 2024

Failed server tests

  • com.appsmith.server.imports.internal.ImportServiceTests#discardChange_addNavigationAndThemeSettingAfterImport_addedNavigationAndThemeSettingRemoved
  • com.appsmith.server.migrations.JsonSchemaMigrationTest#migrateApplicationJsonToLatestSchema_whenFeatureFlagIsOn_returnsIncrementedValue
  • com.appsmith.server.migrations.JsonSchemaMigrationTest#migrateArtifactToLatestSchema_whenFeatureFlagIsOn_returnsIncrementedValue

@sondermanish sondermanish self-assigned this Aug 8, 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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a93268d and 63afe5e.

Files selected for processing (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/migrations/JsonSchemaMigrationTest.java

Copy link

github-actions bot commented Aug 8, 2024

Failed server tests

  • com.appsmith.server.imports.internal.ImportServiceTests#discardChange_addNavigationAndThemeSettingAfterImport_addedNavigationAndThemeSettingRemoved

@sondermanish sondermanish requested a review from a team as a code owner August 9, 2024 06:59
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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 63afe5e and f03353b.

Files selected for processing (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java (1 hunks)

@sondermanish sondermanish added the ok-to-test Required label for CI label Aug 9, 2024
@sondermanish sondermanish merged commit c126604 into release Aug 9, 2024
43 checks passed
@sondermanish sondermanish deleted the fix/release-blocker branch August 9, 2024 08:18
sondermanish added a commit that referenced this pull request Aug 9, 2024
## Description
> 
>
>

Fixes #35536

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 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/10315694999>
> Commit: f03353b
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10315694999&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Fri, 09 Aug 2024 08:16:04 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

- **New Features**
- Enhanced migration logic for server schema versions, ensuring proper
handling of theme settings during migrations from version 6 to 9.
- Introduced methods to establish and set default theme settings for
applications during migration.

- **Bug Fixes**
- Simplified server version retrieval process, ensuring consistent
versioning behavior.

- **Tests**
- Updated tests to reflect changes in server version expectations,
removing unnecessary assertions related to feature flags.
- Streamlined validation logic in migration tests to focus solely on
expected schema versions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Release Blocker This issue must be resolved before the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Uncommitted changes are present on all existing git connected apps
2 participants