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: Remove unused UserData.role #37381

Merged
merged 1 commit into from
Nov 14, 2024
Merged

chore: Remove unused UserData.role #37381

merged 1 commit into from
Nov 14, 2024

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Nov 14, 2024

The role field is not sent by the client and is not used by the server anywhere.

We're not removing the role field in analytics payloads, since changes like that in the past have broken other analytics pipelines (where a field value was null instead of "" started to throw NPEs in some internal workflows). We can solve that as a separate problem later.

Automation

/test sanity authentication

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11830985060
Commit: 986fc89
Cypress dashboard.
Tags: @tag.Sanity, @tag.Authentication
Spec:


Thu, 14 Nov 2024 05:59:04 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Simplified user update requests by removing the role field, streamlining user data management.
  • Bug Fixes

    • Adjusted analytics tracking to exclude user role information, ensuring compliance with updated data handling practices.
  • Documentation

    • Updated test cases to reflect changes in user role management, focusing on name and use case updates instead.

These changes enhance the user experience by simplifying user management and improving data privacy in analytics.

Copy link
Contributor

coderabbitai bot commented Nov 14, 2024

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on the removal of the role property from various data structures related to user management. This includes modifications to interfaces, data transfer objects, and service implementations, ensuring that the role attribute is no longer part of user-related requests or responses. The changes maintain existing functionalities while simplifying the structures involved in user updates and analytics.

Changes

File Change Summary
app/client/src/ce/api/UserApi.tsx Removed optional role property from UpdateUserRequest interface.
app/client/src/ce/sagas/userSagas.tsx Removed role from destructured action.payload in updateUserDetailsSaga.
app/server/appsmith-server/src/main/java/com/appsmith/server/domains/UserData.java Marked role, recentlyUsedWorkspaceIds, and recentlyUsedAppIds as deprecated.
app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/UserSignupRequestDTO.java Marked role as deprecated and removed from UserSignupRequestDTO.
app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/UserUpdateCE_DTO.java Removed role field and updated hasUserDataUpdates method to exclude role check.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCE.java Removed role parameter from identifyInstance method signature.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java Updated identifyUser and identifyInstance methods to omit role handling.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UserServiceCEImpl.java Removed logic for updating user role in updateCurrentUser method.
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/UserSignupCEImpl.java Removed role setting logic from signupAndLoginSuper and signupAndLoginSuperFromFormData.
app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java Removed role setting in test for UserData serialization.
app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java Removed updateRoleOfUser test method and updated updateNameRoleAndUseCaseOfUser method.

Possibly related PRs

Suggested labels

Bug, High, Production, RBAC Product

Suggested reviewers

  • abhvsn
  • nidhi-nair
  • mohanarpit

🎉 In the code we trust,
The role has gone, it's a must!
Simplifying structures, oh what a feat,
User management feels so neat!
With tests updated, and logic refined,
A cleaner codebase is what we find! 🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d90faa2 and 986fc89.

📒 Files selected for processing (11)
  • app/client/src/ce/api/UserApi.tsx (0 hunks)
  • app/client/src/ce/sagas/userSagas.tsx (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/UserData.java (0 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/UserSignupRequestDTO.java (0 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/UserUpdateCE_DTO.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UserServiceCEImpl.java (0 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/UserSignupCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java (0 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java (1 hunks)
💤 Files with no reviewable changes (5)
  • app/client/src/ce/api/UserApi.tsx
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/UserData.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/UserSignupRequestDTO.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UserServiceCEImpl.java
  • app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/CommonConfigTest.java
🔇 Additional comments (9)
app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/UserUpdateCE_DTO.java (2)

23-23: LGTM! Method simplified correctly.

The simplified hasUserDataUpdates() method correctly checks all relevant user data fields.


23-23: Verify API consumers handling user updates

Let's verify that API consumers are not relying on the role field in user updates.

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCE.java (2)

20-21: LGTM! Method signature update aligns with PR objectives.

The removal of the role parameter from identifyInstance is consistent with the goal of removing the unused UserData.role field.


20-21: Verify implementing classes and callers.

This is a breaking change in the interface contract. Let's verify all implementations and callers have been updated.

✅ Verification successful

Based on the results, I can generate the final response as we have found all the necessary information. The search results show:

  1. The interface AnalyticsServiceCE with the updated method signature
  2. The implementation AnalyticsServiceCEImpl with matching signature
  3. The only caller UserSignupCEImpl using the method correctly

All implementations and callers are properly aligned with the interface changes

The method signature changes have been consistently applied across the codebase. The implementation in AnalyticsServiceCEImpl matches the interface, and the single caller in UserSignupCEImpl is using the method with the correct parameters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find implementations of AnalyticsServiceCE
ast-grep --pattern 'class $_ implements $$$AnalyticsServiceCE$$$'

# Find calls to identifyInstance
rg 'identifyInstance\(' -A 2

Length of output: 1466

app/client/src/ce/sagas/userSagas.tsx (1)

420-424: LGTM! Verify API contract compatibility

The removal of the role field from the payload aligns with the PR objective. However, let's verify the API contract to ensure backward compatibility.

✅ Verification successful

Removal of role field is safe

Based on the codebase analysis:

  • The UpdateUserRequest interface in app/client/src/ce/api/UserApi.tsx doesn't include role as a required field
  • No role-related validations were found in the API implementation
  • The API endpoint accepts a subset of user fields: email, name, proficiency, useCase, and intercomConsentGiven
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the API endpoint handles the absence of the role field gracefully
# by looking for any validation or required field checks in the API implementation

# Search for API validation related to user role
ast-grep --pattern 'class $_ implements $_ {
  $$$
  updateUser($payload) {
    $$$
    role
    $$$
  }
  $$$
}'

# Search for any TypeScript interfaces that might still require the role field
rg -g '*.ts' -g '*.tsx' 'interface.*User.*\{[\s\S]*?role.*?\}'

Length of output: 180


Script:

#!/bin/bash
# Let's try a different approach to find API and interface definitions

# Search for updateUser API implementation
rg -g '*.ts' -g '*.tsx' 'updateUser.*\(' -A 5

# Search for User-related interfaces and types
rg -g '*.ts' -g '*.tsx' 'type.*User|interface.*User' -A 5

# Search for role-related validations
rg -g '*.ts' -g '*.tsx' 'role.*required|required.*role'

Length of output: 42066

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java (2)

144-144: LGTM! Change aligns with PR objectives.

Setting role to empty string maintains analytics payload structure while removing dependency on UserData.role.


153-153: LGTM! Consistent handling of role field.

Removing the role parameter and setting role to empty string maintains consistency with identifyUser method.

Also applies to: 164-164

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

445-445: LGTM! Analytics payload change looks good.

Setting role to empty string in analytics properties aligns with the PR objective while preserving analytics pipeline stability.

Let's verify that this is the only place where role is used in analytics events:

✅ Verification successful

The previous search might have been too specific. These new searches will help us:

  1. Find any role-related analytics code with broader patterns
  2. Look for role-related constants used in analytics
  3. Search for analytics event calls that might include role information

Verified: Role field is only used once in analytics properties

The search results confirm that in the analytics context, the role field is only used once in UserSignupCEImpl.java where it's being set to an empty string. Other occurrences of ROLE are unrelated, being used in AI plugins (Google AI, Anthropic, OpenAI) and internal constants.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other analytics-related role usages
rg -l "analyticsProps.*role|role.*analyticsProps" --type java

Length of output: 63


Script:

#!/bin/bash
# Let's try a broader search for analytics properties and role
rg -i "role.*analytics|analytics.*role" --type java -A 2 -B 2

# Also search for any role-related analytics constants
rg "ROLE.*=|=.*ROLE" --type java -A 1 -B 1

# Search for analytics event related code with role
ast-grep --pattern 'analyticsService.sendEvent($$$role$$$)'

Length of output: 9229

app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java (1)

Line range hint 487-505: LGTM! Method rename aligns with role removal.

The test method has been correctly renamed and implementation properly focuses on name and use case updates.

Let's verify that all role-related code has been removed:

✅ Verification successful

The previous search showed role-related methods but we need to specifically verify the UserData class to ensure complete removal of the role field and related code.


Role field removal is complete and test changes are correct

The verification confirms that:

  • No role-related fields or methods exist in the UserData class
  • The test method rename from updateNameRoleAndUseCaseOfUser to updateNameAndUseCaseOfUser is appropriate
  • Other role-related occurrences in the codebase are for different contexts (like workspace roles, plugin roles) and not related to UserData
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to user role in the codebase
# Expect: No occurrences except in migration scripts or documentation

# Search for role-related method names and variables in Java files
rg -t java "updateNameRoleAndUseCase|getUserRole|setRole|getRole" 

# Search for role field references in UserData related files
rg -t java "UserData.*role|role.*UserData"

Length of output: 6350


Script:

#!/bin/bash
# Let's search for any remaining references to role in UserData class and related files
ast-grep --pattern 'class UserData {
  $$$
  $role
  $$$
}'

# Also check for any role-related methods in UserData
ast-grep --pattern 'class UserData {
  $$$
  $role($$$) {
    $$$
  }
  $$$
}'

# Search for UserData references in test files
rg -t java "class.*UserData|UserData.*class" -A 5

Length of output: 9823


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.

@sharat87 sharat87 changed the title Remove unused UserData.role chore: Remove unused UserData.role Nov 14, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 14, 2024
Copy link

Failed server tests

  • com.external.plugins.GoogleAiPluginTest#
  • com.external.plugins.GenerateContentCommandTest#
  • com.external.plugins.services.FieldValidationHelperTest#
  • com.external.plugins.services.features.ImageClassificationServiceImplTest#
  • com.external.plugins.services.features.TextEntityExtractionServiceImplTest#
  • com.external.plugins.services.features.TextSummarizationServiceImplTest#
  • com.external.plugins.services.features.ImageCaptioningServiceImplTest#
  • com.external.plugins.services.features.TextGenerationServiceImplTest#
  • com.external.plugins.services.features.TextClassificationServiceImplTest#
  • com.external.plugins.services.features.ImageEntityExtractionServiceImplTest#
  • com.external.plugins.services.HeadersUtilTest#
  • com.external.plugins.services.AiFeatureServiceFactoryTest#
  • com.external.plugins.AwsLambdaPluginTest#
  • com.external.plugins.DatabricksPluginTest#
  • com.appsmith.git.converters.GsonDoubleToLongConverterTest#
  • com.appsmith.git.helpers.DSLTransformerHelperTest#
  • com.appsmith.git.helpers.FileUtilsImplTest#
  • GsonUnorderedToOrderedSerializationTest#
  • com.external.plugins.AnthropicPluginTest#verifyTestDatasourceReturnsFalse

@sharat87 sharat87 added the ok-to-test Required label for CI label Nov 14, 2024
@sharat87 sharat87 marked this pull request as ready for review November 14, 2024 06:08
@sharat87 sharat87 merged commit 7e209d2 into release Nov 14, 2024
50 checks passed
@sharat87 sharat87 deleted the chore/no-role branch November 14, 2024 08:06
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
The `role` field is not sent by the client and is not used by the server
anywhere.

We're not removing the `role` field in analytics payloads, since changes
like that in the past have broken other analytics pipelines (where a
field value was `null` instead of `""` started to throw NPEs in some
internal workflows). We can solve that as a separate problem later.


## Automation

/test sanity authentication

### 🔍 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/11830985060>
> Commit: 986fc89
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11830985060&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 05:59:04 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

## Release Notes

- **New Features**
- Simplified user update requests by removing the `role` field,
streamlining user data management.
  
- **Bug Fixes**
- Adjusted analytics tracking to exclude user role information, ensuring
compliance with updated data handling practices.

- **Documentation**
- Updated test cases to reflect changes in user role management,
focusing on name and use case updates instead.

These changes enhance the user experience by simplifying user management
and improving data privacy in analytics.

<!-- 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 Nov 20, 2024
The `role` field is not sent by the client and is not used by the server
anywhere.

We're not removing the `role` field in analytics payloads, since changes
like that in the past have broken other analytics pipelines (where a
field value was `null` instead of `""` started to throw NPEs in some
internal workflows). We can solve that as a separate problem later.


## Automation

/test sanity authentication

### 🔍 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/11830985060>
> Commit: 986fc89
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11830985060&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity, @tag.Authentication`
> Spec:
> <hr>Thu, 14 Nov 2024 05:59:04 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

## Release Notes

- **New Features**
- Simplified user update requests by removing the `role` field,
streamlining user data management.
  
- **Bug Fixes**
- Adjusted analytics tracking to exclude user role information, ensuring
compliance with updated data handling practices.

- **Documentation**
- Updated test cases to reflect changes in user role management,
focusing on name and use case updates instead.

These changes enhance the user experience by simplifying user management
and improving data privacy in analytics.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2024
2 tasks
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