Skip to content

Conversation

@subrata71
Copy link
Collaborator

@subrata71 subrata71 commented Nov 25, 2025

Description

When customer shares logs from their instance it becomes really cumbersome to troubleshoot and figure out the main problem. The log file gets cluttered by the following error log:

com.appsmith.server.exceptions.AppsmithException: Please enter a valid parameter anonymousUserId.
	at com.appsmith.server.services.ce.UsagePulseServiceCEImpl.lambda$createPulse$0(UsagePulseServiceCEImpl.java:79)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ Handler com.appsmith.server.controllers.UsagePulseController#create(UsagePulseDTO) [DispatcherHandler]
Original Stack Trace:
		at com.appsmith.server.services.ce.UsagePulseServiceCEImpl.lambda$createPulse$0(UsagePulseServiceCEImpl.java:79)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132)
		at com.appsmith.server.configurations.MDCConfig$MdcContextLifter.onNext(MDCConfig.java:59)
		at reactor.core.publisher.MonoZip$ZipCoordinator.signal(MonoZip.java:297)
		at reactor.core.publisher.MonoZip$ZipInner.onNext(MonoZip.java:478)
		at com.appsmith.server.configurations.MDCConfig$MdcContextLifter.onNext(MDCConfig.java:59)
		at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2570)
		at reactor.core.publisher.MonoZip$ZipInner.onSubscribe(MonoZip.java:470)
		at com.appsmith.server.configurations.MDCConfig$MdcContextLifter.onSubscribe(MDCConfig.java:53)
		at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)
		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)
		at reactor.core.publisher.MonoZip$ZipCoordinator.request(MonoZip.java:220)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onSubscribe(MonoIgnoreThen.java:135)
		at com.appsmith.server.configurations.MDCConfig$MdcContextLifter.onSubscribe(MDCConfig.java:53)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)
		at com.appsmith.server.configurations.MDCConfig$MdcContextLifter.onSubscribe(MDCConfig.java:53)
		at reactor.core.publisher.MonoZip.subscribe(MonoZip.java:129)

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/19664146229
Commit: 5394bfa
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Tue, 25 Nov 2025 09:44:35 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of anonymous-user tracking: invalid or blank anonymous identifiers are now ignored (no error) and logged as warnings.
  • Tests
    • Updated tests to reflect the new behavior where invalid/blank anonymous identifiers are ignored rather than causing errors.

✏️ Tip: You can customize this high-level summary in your review settings.

@subrata71 subrata71 self-assigned this Nov 25, 2025
@subrata71 subrata71 requested a review from abhvsn November 25, 2025 07:40
@subrata71 subrata71 added the ok-to-test Required label for CI label Nov 25, 2025
@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 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Walkthrough

Added logging and softened validation in UsagePulseServiceCEImpl: invalid or blank anonymousUserId and edit-mode mismatches now log a warning and return Mono.empty() instead of throwing; tests updated to expect completion (ignored) rather than exceptions.

Changes

Cohort / File(s) Summary
Service changes
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java
Added @Slf4j logging; replaced exception throws for anonymous-user and viewMode validation with warning logs and Mono.empty() returns; switched null check to StringUtils.isBlank() for anonymousUserId.
Test updates
app/server/appsmith-server/src/test/java/com/appsmith/server/services/UsagePulseServiceTest.java
Renamed two tests to reflect ignored behavior (*_ThrowsException*_Ignored) and changed assertions from expecting AppsmithException to verifyComplete(); removed unused AppsmithException import.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UsagePulseService
    participant Logger

    Client->>UsagePulseService: createPulse(request)
    alt viewMode == true
        UsagePulseService->>UsagePulseService: proceed with normal pulse creation
        UsagePulseService-->>Client: Mono<createdPulse>
    else viewMode == false
        UsagePulseService->>UsagePulseService: check anonymousUserId
        alt anonymousUserId blank
            UsagePulseService->>Logger: warn("anonymousUserId blank, ignoring")
            UsagePulseService-->>Client: Mono.empty()
        else anonymousUserId present
            UsagePulseService->>UsagePulseService: set anonymous flags & associate user
            UsagePulseService-->>Client: Mono<createdPulse>
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify logging messages and levels are appropriate and consistent with observability policies.
  • Confirm no callers rely on the previous exception behavior (integration tests / external clients).
  • Review tests for adequate coverage of both ignored and success branches.

Poem

A gentle log, a quiet skip,
Faults no longer make code trip,
Pulses pass with softer cheer —
Warnings whisper, errors clear. ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ⚠️ Warning PR description lacks issue linkage, provides context and rationale but missing required sections from template. Link the PR to a GitHub issue (fill in Fixes #XXXX), and ensure all required template sections are properly completed before merging.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing an error log for anonymous users in the usage pulse service.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/remove-unnecessary-logs

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🧹 Nitpick comments (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java (2)

52-54: Consider adding debug-level logging for observability.

While silently ignoring these cases reduces log noise, having no trace makes it difficult to verify the behavior is working as intended or to detect if anonymous users are unexpectedly attempting edit-mode operations.

Consider adding a debug log statement:

 } else if (FALSE.equals(usagePulseDTO.getViewMode()) && usagePulseDTO.getAnonymousUserId() != null) {
     // Anonymous users shouldn't hit edit mode pulses; ignore silently to avoid noisy logs.
+    log.debug("Ignoring edit-mode pulse for anonymous user: {}", usagePulseDTO.getAnonymousUserId());
     return Mono.empty();
 }

78-80: Consider adding debug-level logging for observability.

Similar to the earlier change, having at least debug-level visibility into when anonymous pulses are ignored would aid in monitoring and troubleshooting without creating log noise in production.

Consider adding a debug log statement:

 if (StringUtils.isBlank(usagePulseDTO.getAnonymousUserId())) {
     // Anonymous usage pulses without an identifier are ignored to avoid noisy logs.
+    log.debug("Ignoring anonymous usage pulse with blank identifier");
     return Mono.empty();
 }
app/server/appsmith-server/src/test/java/com/appsmith/server/services/UsagePulseServiceTest.java (2)

136-142: Fix test naming inconsistency.

This test method is missing the test_ prefix that other test methods in this class use (e.g., lines 46, 70, 82, 105).

Apply this diff to maintain naming consistency:

-public void createPulse_inEditMode_withAnonymousUser_ignored() {
+public void test_createPulse_inEditMode_withAnonymousUser_ignored() {

65-75: Consider adding test coverage for view-mode with blank anonymous user ID.

There's a gap in test coverage: what happens when viewMode=true but anonymousUserId is blank/null for an anonymous user? Based on the implementation, this should also be silently ignored (via lines 78-80), but there's no test verifying this scenario.

Consider adding a test case:

@Test
@WithUserDetails(value = "anonymousUser")
public void test_AnonymousUserPulse_ViewMode_WithBlankId_Ignored() {
    UsagePulseDTO usagePulseDTO = new UsagePulseDTO();
    usagePulseDTO.setViewMode(true);
    // anonymousUserId is not set, will be null/blank
    
    StepVerifier.create(usagePulseService.createPulse(usagePulseDTO))
        .verifyComplete();
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 700351b and e6c718c.

📒 Files selected for processing (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/UsagePulseServiceTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-unit-tests / server-unit-tests
🔇 Additional comments (1)
app/server/appsmith-server/src/test/java/com/appsmith/server/services/UsagePulseServiceTest.java (1)

66-75: Test correctly validates the silent-ignore behavior.

The test properly verifies that anonymous pulses without an identifier in edit mode are now ignored rather than throwing an exception.

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.helpers.UserUtilsTest#makeInstanceAdministrator_WhenUserAlreadyAdmin_MaintainsPermissionsSuccessfully

Copy link
Contributor

@abhvsn abhvsn left a comment

Choose a reason for hiding this comment

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

@subrata71 we added these logs to figure out the underlying issue where client may trigger errorneous calls to trigger usage pulse. As you can see we don't allow edit app access to anonymous user so we should never end up in this state. The fact that we are seeing these logs mean that client is at fault. Can we figure out the root cause instead of silently ignoring it.

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

🧹 Nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java (1)

83-85: Graceful handling of missing anonymous user id; consider log level if this is high-volume

Using StringUtils.isBlank avoids NPEs and treats empty/whitespace IDs correctly, and returning Mono.empty() matches the “ignore bad pulses” behavior. If this condition is expected to be frequent in some deployments, you might consider downgrading to INFO/DEBUG later to avoid accumulating many warnings in instance logs.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6c718c and 5394bfa.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-25T06:50:40.623Z
Learnt from: trishaanand
Repo: appsmithorg/appsmith PR: 38359
File: app/server/appsmith-server/src/main/java/com/appsmith/server/authentication/handlers/ce/CustomOAuth2UserServiceCEImpl.java:78-82
Timestamp: 2024-12-25T06:50:40.623Z
Learning: In `CustomOAuth2UserServiceCEImpl`, the second repository call for finding users by case-insensitive email is needed because older users might have uppercase or mixed-case emails, while new users have emails stored in lowercase.

Applied to files:

  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: server-unit-tests / server-unit-tests
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/UsagePulseServiceCEImpl.java (2)

18-29: Appropriate use of @Slf4j for lightweight logging

Importing lombok.extern.slf4j.Slf4j and annotating the service keeps logging boilerplate-free and is consistent with the new log.warn usage below. No issues here.


55-59: Soft-failing edit-mode pulses from anonymous users looks consistent with the PR goal

Switching from throwing to logging a concise warning and returning Mono.empty() for viewMode=false + anonymousUserId present removes noisy stack traces while still surfacing intent in logs. Just make sure all call sites treat a completed empty Mono as “best-effort/no-op” and don’t rely on errors here for control flow.

@subrata71 subrata71 requested a review from abhvsn November 25, 2025 09:17
@github-actions
Copy link

Failed server tests

  • com.appsmith.server.helpers.UserUtilsTest#makeInstanceAdministrator_WhenUserAlreadyAdmin_MaintainsPermissionsSuccessfully

@subrata71 subrata71 merged commit 5fb5e00 into release Nov 25, 2025
52 of 54 checks passed
@subrata71 subrata71 deleted the chore/remove-unnecessary-logs branch November 25, 2025 10:44
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