Skip to content

chore: Code split env manager for introducing blacklisted variables#39963

Merged
abhvsn merged 2 commits intoreleasefrom
chore/block-admin-settings-updates-behind-flag
Mar 28, 2025
Merged

chore: Code split env manager for introducing blacklisted variables#39963
abhvsn merged 2 commits intoreleasefrom
chore/block-admin-settings-updates-behind-flag

Conversation

@abhvsn
Copy link
Contributor

@abhvsn abhvsn commented Mar 28, 2025

Description

Code split PR for env manager for the corresponding PR at https://github.com/appsmithorg/appsmith-ee/pull/6799

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.

/test Settings

🔍 Cypress test results

Tip

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


Fri, 28 Mar 2025 09:49:43 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced administrative settings with multi-organization support to improve category filtering based on feature flags.
  • Refactor

    • Upgraded environment variable management to employ asynchronous processing and stricter filtering of sensitive values.
  • Tests

    • Revised the test suite to better validate asynchronous behavior and the improved handling of environment variables.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

This pull request updates both client and server code. On the client side, the function for filtering general categories now accepts an optional feature flag parameter and the AdminSettings left pane integrates a feature flag check. On the server side, new interfaces and classes are introduced for handling blacklisted environment variables. Additionally, the environment management components have been updated to use reactive programming patterns, with method signatures and error handling modified accordingly. Test cases are adjusted to work with reactive streams.

Changes

File(s) Change Summary
app/client/.../adminSettingsHelpers.ts
app/client/.../LeftPane.tsx
Updated the getFilteredGeneralCategories signature to add an optional featureFlags parameter. LeftPane now uses a feature flag (isMultiOrgEnabled) via useFeatureFlag and passes it into the filtering function.
app/server/.../helpers/BlacklistedEnvVariableHelper.java
app/server/.../helpers/BlacklistedEnvVariableHelperImpl.java
app/server/.../helpers/ce/BlacklistedEnvVariableHelperCE.java
app/server/.../helpers/ce/BlacklistedEnvVariableHelperCEImpl.java
Added new interfaces and implementations (both standard and CE versions) for handling blacklisted environment variables.
app/server/.../solutions/EnvManagerImpl.java
app/server/.../solutions/ce/EnvManagerCE.java
app/server/.../solutions/ce/EnvManagerCEImpl.java
Modified constructors and method signatures to include the new BlacklistedEnvVariableHelper dependency. Updated methods (e.g. transformEnvContent) to return reactive types (Mono) and adjusted file operation and error handling logic.
app/server/.../solutions/EnvManagerTest.java Revised tests to use reactive assertions with StepVerifier and added a new mock bean for BlacklistedEnvVariableHelper.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant LP as LeftPane Component
    participant GH as GeneralCategories Helper

    U->>LP: Render Admin Settings
    LP->>LP: Check feature flag (useFeatureFlag)
    LP->>GH: Call getFilteredGeneralCategories(categories, {license_multi_org_enabled: isMultiOrgEnabled})
    GH-->>LP: Return filtered categories
    LP-->>U: Display filtered results
Loading
sequenceDiagram
    participant C as Client
    participant EM as EnvManagerCEImpl
    participant BVH as BlacklistedEnvVariableHelper

    C->>EM: Call transformEnvContent(envContent, changes)
    EM->>BVH: Retrieve/filter blacklisted environment variables
    BVH-->>EM: Provide filtered variables
    EM->>EM: Process changes reactively (publishOn, error handling)
    EM-->>C: Return Mono<List<String>> with transformed content
Loading

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test, Task, Production, Google Sheets

Suggested reviewers

  • nidhi-nair
  • sagar-qa007

Poem

In lines of code, a flag now flies,
New parameters spark in clever guise.
From client flair to reactive might,
Blacklisted checks guide our insight.
Tests now buzz with a reactive tune,
Cheering progress from morning to noon!
🚀✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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 Mar 28, 2025
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 comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java (1)

179-239: ⚠️ Potential issue

Reactive transformEnvContent with blacklisted variable removal.
The move to Mono<List<String>> is consistent. Be cautious with the loop removing map entries during iteration (lines 199–203) as HashMap is not safe for removals while iterating over keySet(); this can cause ConcurrentModificationException. Consider iterating over entrySet in a safe manner (e.g., using an iterator).

- for (String key : updatedChanges.keySet()) {
-   if (blacklistedEnvVariable.contains(key)) {
-       updatedChanges.remove(key);
-   }
- }
+ for (Iterator<String> it = updatedChanges.keySet().iterator(); it.hasNext();) {
+   var key = it.next();
+   if (blacklistedEnvVariable.contains(key)) {
+       it.remove();
+   }
+ }
🧹 Nitpick comments (3)
app/client/src/ce/utils/adminSettingsHelpers.ts (1)

73-78: Consider adding filter logic for the multi-org feature flag.

The function currently returns all categories without filtering based on the feature flags. If the purpose of adding the feature flag parameter is to conditionally show/hide categories, you should implement that logic.

 return categories
   ?.map((category: Category) => {
+    // Example of potential implementation
+    if (featureFlags?.license_multi_org_enabled === false && category.isMultiOrgOnly) {
+      return null;
+    }
     return category;
   })
   .filter(Boolean);
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/BlacklistedEnvVariableHelperCE.java (1)

5-7: Method name should be plural since it returns a collection

The method returns a Set but uses singular "Variable" in its name.

-    Set<String> getBlacklistedEnvVariableForAppsmithCloud(String organizationId);
+    Set<String> getBlacklistedEnvVariablesForAppsmithCloud(String organizationId);
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/BlacklistedEnvVariableHelperCEImpl.java (1)

7-8: Method name should be plural to match its return type

For consistency with the return type (a collection), consider renaming this method to use the plural form.

-    public Set<String> getBlacklistedEnvVariableForAppsmithCloud(String organizationId) {
+    public Set<String> getBlacklistedEnvVariablesForAppsmithCloud(String organizationId) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 300e7d7 and ec228ef.

📒 Files selected for processing (10)
  • app/client/src/ce/utils/adminSettingsHelpers.ts (1 hunks)
  • app/client/src/pages/AdminSettings/LeftPane.tsx (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/BlacklistedEnvVariableHelper.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/BlacklistedEnvVariableHelperImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/BlacklistedEnvVariableHelperCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/BlacklistedEnvVariableHelperCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EnvManagerImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java (12 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/EnvManagerTest.java (6 hunks)
🧰 Additional context used
🧬 Code Definitions (3)
app/client/src/pages/AdminSettings/LeftPane.tsx (1)
app/client/src/ce/utils/adminSettingsHelpers.ts (1)
  • getFilteredGeneralCategories (68-78)
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java (1)
  • FieldNameCE (3-212)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/BlacklistedEnvVariableHelperImpl.java (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/BlacklistedEnvVariableHelperCEImpl.java (1)
  • BlacklistedEnvVariableHelperCEImpl (5-10)
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EnvManagerImpl.java (1)
  • Component (24-66)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (29)
app/client/src/pages/AdminSettings/LeftPane.tsx (2)

205-207: Good addition of feature flag for multi-org support.

This correctly adds a check for the multi-organization feature flag which will be needed for conditional rendering.


213-215: Implementation correctly passes the feature flag to helper function.

The updated call now passes the feature flag to getFilteredGeneralCategories, which aligns with the updated function signature in the adminSettingsHelpers file.

app/client/src/ce/utils/adminSettingsHelpers.ts (1)

68-72: Function signature update is correct but implementation still pending.

The function now accepts the featureFlags parameter but doesn't utilize it yet, as indicated by the ESLint comment. This is likely preparation for future filtering logic based on feature flags.

Is there a future PR planned to implement the actual filtering logic based on this feature flag? Once that's implemented, we should update the ESLint comment.

app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/BlacklistedEnvVariableHelper.java (1)

1-5: Interface looks clean and follows project patterns

This interface properly extends the CE version, following the established pattern in the codebase for separating core functionality from specific implementations.

app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/BlacklistedEnvVariableHelperImpl.java (1)

1-10: Implementation is correctly configured

The implementation properly extends the CE implementation class and implements the interface. Spring component annotation and Lombok's RequiredArgsConstructor are appropriately used for dependency injection.

app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/BlacklistedEnvVariableHelperCEImpl.java (1)

6-9: Implementation correctly returns an empty set

The implementation is minimal but correct. Since this is likely a placeholder for the CE version, returning an empty set is appropriate.

app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCE.java (1)

14-14: Adopting reactive return type.
Switching the method signature from List<String> to Mono<List<String>> aligns with the reactive paradigm and looks appropriate. Make sure all calling sites handle the new reactive flow.

app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/EnvManagerTest.java (12)

9-126: Introducing BlacklistedEnvVariableHelper and updated constructor spy.
The addition of the BlacklistedEnvVariableHelper mock and the updated constructor parameters maintain consistency with the new reactive method changes. Using a spy on EnvManagerImpl is reasonable for partial mocking. Ensure each mock is verified in relevant test scenarios.


133-142: Verifying transformEnvContent with StepVerifier (first case).
The test verifies updates to a single variable. This looks fine. Keep an eye on edge cases (e.g., empty strings or null).


144-153: Verifying transformEnvContent with StepVerifier (second case).
Same pattern of verification for a different variable. Looks consistent and thorough.


155-166: Verifying transformEnvContent (third case).
Repeats the StepVerifier pattern for a third variable. Clear test coverage, no concerns here.


167-181: Multiple changes in transformEnvContent.
This verifies simultaneous changes to multiple variables. Good coverage. No issues spotted.


187-208: Testing empty vs. non-empty updates.
Coverage of edge scenarios for empty environment variable values is key. Good job adding these corner cases.


215-255: Quoted values transformations.
These tests confirm correct handling of quotes and special characters. The usage of StepVerifier is consistent, and the coverage of string escaping is thorough.


294-305: Disallowed variable scenario.
Validates that blacklisted changes result in errors. Nicely ensures the environment manager blocks forbidden variables.


312-327: Adding new environment variable.
Test ensures new variables can be introduced properly. Looks consistent.


334-349: Setting values containing quotes.
Verifies that special quoting logic works. Good test coverage for advanced quoting cases.


366-383: Filtering out empty values (first scenario).
The getAllNonEmpty() usage is tested to ensure no empty-value entries are returned. Straightforward and correct.


385-409: Filtering out empty values (multiple variables).
Extends the prior test using more variables. Very thorough. No issues here.

app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/EnvManagerImpl.java (2)

6-7: New import for BlacklistedEnvVariableHelper.
Importing the helper fosters blacklisted variable checks. Aligns with the recent changes.


44-65: Constructor injection for EmailService and BlacklistedEnvVariableHelper.
Passing these dependencies into the superclass is consistent with the new layering. Looks clean and well-structured.

app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java (8)

16-16: New import for BlacklistedEnvVariableHelper.
The import is correct and supports blacklisted variable logic in this class.


50-51: Using Schedulers and Context from Reactor.
Inclusion of Schedulers and Context indicates a more robust reactive approach. Make sure to confirm proper concurrency usage.


88-88: Added reference to FieldNameCE.ORGANIZATION_ID.
Ensures correct context-based retrieval of the organization ID for blacklisted checks.


119-120: Introducing blacklistedEnvVariableHelper field.
This field ties into filtering disallowed environment variables. No immediate issues.


147-148: Added blacklistedEnvVariableHelper to constructor parameters.
The constructor change keeps the class consistent with the rest of the codebase.


166-166: Storing blacklistedEnvVariableHelper in the class field.
Straightforward assignment. Aligns with best practices for dependency injection.


373-392: applyChanges referencing applyChangesToEnvFileWithoutAclCheck.
The high-level logic for environment updates and ACL checks is coherent. No additional issues noted.


727-741: getAllNonEmpty now includes blacklisted filtering.
The approach to remove blacklisted entries with the organization ID is correct. Observed no other issues.

@abhvsn abhvsn added the ok-to-test Required label for CI label Mar 28, 2025
@abhvsn abhvsn merged commit 1e5b502 into release Mar 28, 2025
53 checks passed
@abhvsn abhvsn deleted the chore/block-admin-settings-updates-behind-flag branch March 28, 2025 11:10
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
…ppsmithorg#39963)

## Description
Code split PR for env manager for the corresponding PR at
appsmithorg/appsmith-ee#6799

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

/test Settings

### 🔍 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/14125869636>
> Commit: ec228ef
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14125869636&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Settings`
> Spec:
> <hr>Fri, 28 Mar 2025 09:49:43 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Enhanced administrative settings with multi-organization support to
improve category filtering based on feature flags.

- **Refactor**
- Upgraded environment variable management to employ asynchronous
processing and stricter filtering of sensitive values.

- **Tests**
- Revised the test suite to better validate asynchronous behavior and
the improved handling of environment variables.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
…ppsmithorg#39963)

## Description
Code split PR for env manager for the corresponding PR at
appsmithorg/appsmith-ee#6799

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

/test Settings

### 🔍 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/14125869636>
> Commit: ec228ef
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14125869636&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Settings`
> Spec:
> <hr>Fri, 28 Mar 2025 09:49:43 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Enhanced administrative settings with multi-organization support to
improve category filtering based on feature flags.

- **Refactor**
- Upgraded environment variable management to employ asynchronous
processing and stricter filtering of sensitive values.

- **Tests**
- Revised the test suite to better validate asynchronous behavior and
the improved handling of environment variables.

<!-- 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

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants