Skip to content

Conversation

@ZiyamSanthosh
Copy link
Contributor

@ZiyamSanthosh ZiyamSanthosh commented Dec 18, 2025

This introduces the Fraud detection configuration management APIs through the existing Configs Mgt endpoint

Related issue:

Summary by CodeRabbit

  • New Features

    • Added tenant-scoped fraud detection configuration API (GET/PUT) to retrieve and update fraud detection settings.
    • Introduced configurable options: publish user info, publish device metadata, log request payloads.
    • Added event-driven configuration with per-event toggles and customizable event properties (key/value pairs).
    • Public API schemas added for FraudDetectionConfig, EventConfig, and EventProperty.
  • Bug Fixes

    • Added explicit error codes for fraud-detection retrieve/update operations.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

Adds tenant-level fraud detection configuration: new provided dependencies, OSGi wiring for FraudDetectionConfigsService, service constructor injection and API methods, factory wiring, REST endpoints and OpenAPI schemas, plus two new error codes.

Changes

Cohort / File(s) Summary
Dependency Additions
pom.xml, components/.../configs.common/pom.xml, components/.../configs.v1/pom.xml
Added org.wso2.carbon.identity.framework:org.wso2.carbon.identity.fraud.detection.core with scope provided.
Service Holder & Error Constants
components/.../configs.common/src/.../ConfigsServiceHolder.java, components/.../configs.common/src/.../Constants.java
Added OSGi lookup holder and public getter for FraudDetectionConfigsService; appended ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE and ERROR_CODE_FRAUD_DETECTION_CONFIG_UPDATE to error enum.
Service Layer
components/.../configs.v1/src/.../core/ServerConfigManagementService.java
Injected FraudDetectionConfigsService via constructor; added getFraudDetectionConfigs() and updateFraudDetectionConfigs(...); added DTO↔model mapping helpers and centralized exception handling for fraud config operations.
Factory & REST API Layer
components/.../configs.v1/src/.../factories/ServerConfigManagementServiceFactory.java, components/.../configs.v1/src/.../impl/ConfigsApiServiceImpl.java
Factory retrieves FraudDetectionConfigsService from holder with null-check and passes it to service constructor; REST impl adds getFraudDetectionConfigs() and updateFraudDetectionConfigs(...) endpoints delegating to the service.
OpenAPI Schema Definition
components/.../configs.v1/src/main/resources/configs.yaml
Added /configs/fraud-detection GET and PUT operations and schemas: FraudDetectionConfig, EventConfig, EventProperty.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant API as ConfigsApiServiceImpl
    participant Service as ServerConfigManagementService
    participant Core as FraudDetectionConfigsService

    Client->>API: GET /configs/fraud-detection
    API->>Service: getFraudDetectionConfigs()
    Service->>Core: fetch tenant fraud detection config
    Core-->>Service: FraudDetectionConfigDTO
    Service-->>API: FraudDetectionConfig (mapped)
    API-->>Client: 200 OK

    Client->>API: PUT /configs/fraud-detection {payload}
    API->>Service: updateFraudDetectionConfigs(payload)
    Service->>Core: update tenant fraud detection config (DTO)
    Core-->>Service: updated FraudDetectionConfigDTO
    Service-->>API: FraudDetectionConfig (mapped)
    API-->>Client: 202/200 Accepted
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review DTO ↔ model mapping and null-safety in ServerConfigManagementService
  • Validate exception-to-APIError mapping and correct usage of new error codes
  • Verify factory null-check and OSGi lookup in ConfigsServiceHolder
  • Confirm OpenAPI schema fields align with DTO/model properties

Poem

🐰 I hopped in quick with a config to guard,
New endpoints and wiring to catch every card,
DTOs and services stitched in a row,
Errors called out so the callers will know,
A little rabbit cheer for the code we guard!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is minimal and lacks required template sections such as Purpose (with detailed problem statement), Goals, Approach, User stories, Developer Checklist, Release notes, Documentation links, Testing details, Security checks, and other mandatory sections. Expand the description to follow the repository template: add Purpose with problem statement and links, Goals, Approach, User stories, Developer Checklist completion status, Release notes, Documentation, and Testing/Security sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: introducing fraud detection configuration support via the ConfigsAPI, which aligns with the changeset's core objective.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c94cbae and df0b0bb.

⛔ Files ignored due to path filters (5)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/ConfigsApi.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/ConfigsApiService.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventConfig.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventProperty.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java is excluded by !**/gen/**
📒 Files selected for processing (9)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (7 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (2 hunks)
  • pom.xml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java
🧰 Additional context used
🧬 Code graph analysis (3)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (1)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java (1)
  • FraudDetectionConfig (36-175)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (4)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventConfig.java (1)
  • EventConfig (36-153)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventProperty.java (1)
  • EventProperty (33-120)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java (1)
  • FraudDetectionConfig (36-175)
components/org.wso2.carbon.identity.api.server.common/src/main/java/org/wso2/carbon/identity/api/server/common/ContextLoader.java (1)
  • ContextLoader (42-146)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java (1)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java (1)
  • ConfigsServiceHolder (37-204)
🔇 Additional comments (6)
pom.xml (1)

548-553: Fraud detection core dependency wiring looks consistent

The new org.wso2.carbon.identity.fraud.detection.core dependency follows the existing identity.framework pattern (shared version property, provided scope). No issues from a dependency-management perspective.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml (1)

188-192: Module-level fraud detection dependency matches root configuration

Adding org.wso2.carbon.identity.fraud.detection.core in provided scope here is consistent with the root POM and with how other framework services are consumed.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (1)

26-27: Fraud detection config endpoints are correctly wired to the core service

getFraudDetectionConfigs and updateFraudDetectionConfigs(FraudDetectionConfig) follow the same delegation pattern as existing endpoints and return 200 OK with the FraudDetectionConfig payload, matching the OpenAPI definition. No functional issues spotted here.

Also applies to: 135-139, 230-234

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (1)

1124-1200: Fraud detection API path and schemas align with implementation

The /configs/fraud-detection GET/PUT operations use 200 responses with FraudDetectionConfig payloads, matching ConfigsApiServiceImpl. The FraudDetectionConfig, EventConfig, and EventProperty schemas closely reflect the generated Java models, so the wire format is coherent end‑to‑end.

Also applies to: 1586-1630

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java (1)

7-8: FraudDetectionConfigsService injection into ServerConfigManagementService is correct

Fetching FraudDetectionConfigsService from ConfigsServiceHolder, null‑checking it, and passing it as the final constructor argument keeps the factory consistent with other mandatory services and matches the updated ServerConfigManagementService signature.

Also applies to: 34-36, 65-67, 69-76

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (1)

51-54: Fraud detection service dependency is cleanly integrated

The added imports, fraudDetectionConfigsService field, and extended constructor parameter list are consistent with the factory wiring and the rest of the class’ dependency style. The new field is final and only used in the dedicated fraud-detection methods, which keeps concerns localized.

Also applies to: 95-100, 127-128, 152-180


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.

Comment on lines +2034 to +2036
public FraudDetectionConfig getFraudDetectionConfigs() {

String tenantDomain = ContextLoader.getTenantDomainFromContext();

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
public FraudDetectionConfig getFraudDetectionConfigs() {
String tenantDomain = ContextLoader.getTenantDomainFromContext();
public FraudDetectionConfig getFraudDetectionConfigs() {
String tenantDomain = ContextLoader.getTenantDomainFromContext();
log.info("Retrieving fraud detection configurations for tenant: " + tenantDomain);

Comment on lines +2047 to +2049
public FraudDetectionConfig updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {

String tenantDomain = ContextLoader.getTenantDomainFromContext();

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 2

Suggested change
public FraudDetectionConfig updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {
String tenantDomain = ContextLoader.getTenantDomainFromContext();
public FraudDetectionConfig updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {
String tenantDomain = ContextLoader.getTenantDomainFromContext();
log.info("Updating fraud detection configurations for tenant: " + tenantDomain);

Comment on lines +65 to +67
if (fraudDetectionConfigsService == null) {
throw new IllegalStateException("FraudDetectionConfigsService is not available from OSGi context.");
}

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 3

Suggested change
if (fraudDetectionConfigsService == null) {
throw new IllegalStateException("FraudDetectionConfigsService is not available from OSGi context.");
}
if (fraudDetectionConfigsService == null) {
log.error("FraudDetectionConfigsService is not available from OSGi context.");
throw new IllegalStateException("FraudDetectionConfigsService is not available from OSGi context.");
}

dcrConfigurationMgtService,
jwtClientAuthenticatorMgtService);
jwtClientAuthenticatorMgtService,
fraudDetectionConfigsService);

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 4

Suggested change
fraudDetectionConfigsService);
fraudDetectionConfigsService);
log.info("ServerConfigManagementService initialized successfully with all required services.");

Comment on lines +135 to +139
@Override
public Response getFraudDetectionConfigs() {

return Response.ok().entity(configManagementService.getFraudDetectionConfigs()).build();
}

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 5

Suggested change
@Override
public Response getFraudDetectionConfigs() {
return Response.ok().entity(configManagementService.getFraudDetectionConfigs()).build();
}
@Override
public Response getFraudDetectionConfigs() {
log.debug("Fetching fraud detection configurations.");
return Response.ok().entity(configManagementService.getFraudDetectionConfigs()).build();
}

Comment on lines +230 to +234
@Override
public Response updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {

return Response.ok().entity(configManagementService.updateFraudDetectionConfigs(fraudDetectionConfig)).build();
}

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 6

Suggested change
@Override
public Response updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {
return Response.ok().entity(configManagementService.updateFraudDetectionConfigs(fraudDetectionConfig)).build();
}
@Override
public Response updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {
log.info("Updating fraud detection configurations.");
return Response.ok().entity(configManagementService.updateFraudDetectionConfigs(fraudDetectionConfig)).build();
}

Copy link

@wso2-engineering wso2-engineering bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
  • Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.

✅ Before merging this pull request:

  • Review all AI-generated comments for accuracy and relevance.
  • Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Comment Accepted (Y/N) Reason
#### Log Improvement Suggestion No: 1
#### Log Improvement Suggestion No: 2
#### Log Improvement Suggestion No: 3
#### Log Improvement Suggestion No: 4
#### Log Improvement Suggestion No: 5
#### Log Improvement Suggestion No: 6

Copy link

@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: 7

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92fa916 and 480be28.

⛔ Files ignored due to path filters (5)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/ConfigsApi.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/ConfigsApiService.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventConfig.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventProperty.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java is excluded by !**/gen/**
📒 Files selected for processing (9)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (7 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (2 hunks)
  • pom.xml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (5)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventConfig.java (1)
  • EventConfig (36-153)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventProperty.java (1)
  • EventProperty (33-120)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java (1)
  • FraudDetectionConfig (36-175)
components/org.wso2.carbon.identity.api.server.common/src/main/java/org/wso2/carbon/identity/api/server/common/ContextLoader.java (1)
  • ContextLoader (42-146)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java (1)
  • Constants (22-252)
🔇 Additional comments (9)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml (1)

188-192: LGTM - Dependency addition follows conventions.

The fraud detection core dependency is correctly added with provided scope, which is appropriate for OSGi runtime dependencies.

pom.xml (1)

548-553: LGTM - Dependency management follows standard patterns.

The fraud detection core dependency is correctly declared in dependency management with appropriate version property reference and scope.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (1)

1586-1630: LGTM - Schema definitions are well-structured.

The FraudDetectionConfig, EventConfig, and EventProperty schemas are clearly defined with appropriate descriptions and examples. The nested structure logically represents the fraud detection configuration hierarchy.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml (1)

85-89: LGTM - Dependency addition is consistent.

The fraud detection core dependency is appropriately added with provided scope, following the same pattern as other framework dependencies in this module.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java (1)

7-7: LGTM - Service wiring follows established patterns.

The FraudDetectionConfigsService is wired consistently with the existing services:

  • Retrieved from ConfigsServiceHolder
  • Validated with a null check
  • Passed to the ServerConfigManagementService constructor

The implementation follows the same pattern as the other seven services in this factory.

Also applies to: 34-35, 65-67, 74-75

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (1)

135-139: LGTM - Implementation follows existing endpoint patterns.

Both endpoints correctly delegate to configManagementService for business logic, which is consistent with other endpoints in this class.

Note: There's a response status code mismatch between the OpenAPI spec (202) and this implementation (200), which has been flagged separately in the configs.yaml review.

Also applies to: 230-234

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java (1)

26-26: LGTM - Service holder follows OSGi service access patterns.

The FraudDetectionConfigsService holder implementation is consistent with the other nine service holders in this class:

  • Uses the standard static inner class pattern for lazy initialization
  • Retrieves the service via PrivilegedCarbonContext OSGi lookup
  • Provides a public getter with appropriate JavaDoc

Also applies to: 98-103, 195-203

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (2)

153-153: LGTM: Service wiring follows established patterns.

The fraud detection service is properly injected via constructor and stored as a final field, consistent with other service dependencies in this class.

Also applies to: 169-170, 179-179


2115-2152: LGTM: Exception handler follows established patterns.

The handleFraudDetectionConfigException() method correctly handles both client and server exceptions, maps them to appropriate HTTP status codes, and follows the same pattern as other exception handlers in this class.

Comment on lines +2034 to +2045
public FraudDetectionConfig getFraudDetectionConfigs() {

String tenantDomain = ContextLoader.getTenantDomainFromContext();
try {
FraudDetectionConfigDTO fraudDetectionConfigDTO
= fraudDetectionConfigsService.getFraudDetectionConfigs(tenantDomain);
return buildFraudDetectionConfig(fraudDetectionConfigDTO);
} catch (FraudDetectionConfigServerException e) {
throw handleFraudDetectionConfigException(e,
Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE, null);
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Catch the base exception type, not just server exceptions.

The catch block only handles FraudDetectionConfigServerException. If FraudDetectionConfigClientException is thrown (e.g., validation errors), it won't be caught, resulting in unhandled exceptions.

🔎 Apply this diff to catch all fraud detection exceptions:
     public FraudDetectionConfig getFraudDetectionConfigs() {

         String tenantDomain = ContextLoader.getTenantDomainFromContext();
         try {
             FraudDetectionConfigDTO fraudDetectionConfigDTO
                     = fraudDetectionConfigsService.getFraudDetectionConfigs(tenantDomain);
             return buildFraudDetectionConfig(fraudDetectionConfigDTO);
-        } catch (FraudDetectionConfigServerException e) {
+        } catch (IdentityFraudDetectionException e) {
             throw handleFraudDetectionConfigException(e,
                     Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE, null);
         }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public FraudDetectionConfig getFraudDetectionConfigs() {
String tenantDomain = ContextLoader.getTenantDomainFromContext();
try {
FraudDetectionConfigDTO fraudDetectionConfigDTO
= fraudDetectionConfigsService.getFraudDetectionConfigs(tenantDomain);
return buildFraudDetectionConfig(fraudDetectionConfigDTO);
} catch (FraudDetectionConfigServerException e) {
throw handleFraudDetectionConfigException(e,
Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE, null);
}
}
public FraudDetectionConfig getFraudDetectionConfigs() {
String tenantDomain = ContextLoader.getTenantDomainFromContext();
try {
FraudDetectionConfigDTO fraudDetectionConfigDTO
= fraudDetectionConfigsService.getFraudDetectionConfigs(tenantDomain);
return buildFraudDetectionConfig(fraudDetectionConfigDTO);
} catch (IdentityFraudDetectionException e) {
throw handleFraudDetectionConfigException(e,
Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE, null);
}
}
🤖 Prompt for AI Agents
In
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java
around lines 2034-2045, the current catch only handles
FraudDetectionConfigServerException so FraudDetectionConfigClientException
(validation/client errors) can escape; change the catch to the common base
exception (e.g., FraudDetectionConfigException) so all fraud-detection-related
exceptions are caught and then call the existing
handleFraudDetectionConfigException(...) with the caught exception and the same
error code/context to rethrow a properly handled API error.

Comment on lines +2047 to +2059
public FraudDetectionConfig updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {

String tenantDomain = ContextLoader.getTenantDomainFromContext();
try {
FraudDetectionConfigDTO fraudDetectionConfigDTO =
fraudDetectionConfigsService.updateFraudDetectionConfigs(
buildFraudDetectionConfigDTO(fraudDetectionConfig), tenantDomain);
return buildFraudDetectionConfig(fraudDetectionConfigDTO);
} catch (FraudDetectionConfigServerException e) {
throw handleFraudDetectionConfigException(e,
Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_UPDATE, null);
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Catch the base exception type, not just server exceptions.

Same issue as getFraudDetectionConfigs() - only FraudDetectionConfigServerException is caught, leaving client exceptions unhandled.

🔎 Apply this diff to catch all fraud detection exceptions:
     public FraudDetectionConfig updateFraudDetectionConfigs(FraudDetectionConfig fraudDetectionConfig) {

         String tenantDomain = ContextLoader.getTenantDomainFromContext();
         try {
             FraudDetectionConfigDTO fraudDetectionConfigDTO =
                     fraudDetectionConfigsService.updateFraudDetectionConfigs(
                             buildFraudDetectionConfigDTO(fraudDetectionConfig), tenantDomain);
             return buildFraudDetectionConfig(fraudDetectionConfigDTO);
-        } catch (FraudDetectionConfigServerException e) {
+        } catch (IdentityFraudDetectionException e) {
             throw handleFraudDetectionConfigException(e,
                     Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_UPDATE, null);
         }
     }
🤖 Prompt for AI Agents
In
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java
around lines 2047 to 2059, the updateFraudDetectionConfigs method currently only
catches FraudDetectionConfigServerException leaving client-side exceptions
unhandled; change the catch clause to catch the base
FraudDetectionConfigException (the common superclass for server and client fraud
detection exceptions) and pass that exception into
handleFraudDetectionConfigException exactly as before so both client and server
errors are handled uniformly.

Comment on lines +2061 to +2089
private FraudDetectionConfig buildFraudDetectionConfig(FraudDetectionConfigDTO dto) {

FraudDetectionConfig fraudDetectionConfig = new FraudDetectionConfig();
fraudDetectionConfig.setPublishUserInfo(dto.isPublishUserInfo());
fraudDetectionConfig.setPublishDeviceMetadata(dto.isPublishDeviceMetadata());
fraudDetectionConfig.setLogRequestPayload(dto.isLogRequestPayload());

List<EventConfig> eventConfigs = new ArrayList<>();
dto.getEvents().forEach((eventName, eventConfigDTO) -> {

List<EventProperty> eventProperties = new ArrayList<>();
eventConfigDTO.getProperties().forEach((key, value) -> {

EventProperty eventProperty = new EventProperty();
eventProperty.setPropertyKey(key);
eventProperty.setPropertyValue(value);
eventProperties.add(eventProperty);
});

EventConfig eventConfig = new EventConfig();
eventConfig.setEventName(eventName);
eventConfig.setEnabled(eventConfigDTO.isEnabled());
eventConfig.setProperties(eventProperties);
eventConfigs.add(eventConfig);
});

fraudDetectionConfig.setEvents(eventConfigs);
return fraudDetectionConfig;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add null safety checks for collections.

The method calls forEach() on dto.getEvents() (line 2069) and eventConfigDTO.getProperties() (line 2072) without null checks, which will throw NPE if these collections are null.

🔎 Apply this diff to add defensive null checks:
     private FraudDetectionConfig buildFraudDetectionConfig(FraudDetectionConfigDTO dto) {

         FraudDetectionConfig fraudDetectionConfig = new FraudDetectionConfig();
         fraudDetectionConfig.setPublishUserInfo(dto.isPublishUserInfo());
         fraudDetectionConfig.setPublishDeviceMetadata(dto.isPublishDeviceMetadata());
         fraudDetectionConfig.setLogRequestPayload(dto.isLogRequestPayload());

         List<EventConfig> eventConfigs = new ArrayList<>();
-        dto.getEvents().forEach((eventName, eventConfigDTO) -> {
+        Map<String, EventConfigDTO> events = dto.getEvents();
+        if (events != null) {
+            events.forEach((eventName, eventConfigDTO) -> {

-            List<EventProperty> eventProperties = new ArrayList<>();
-            eventConfigDTO.getProperties().forEach((key, value) -> {
+                List<EventProperty> eventProperties = new ArrayList<>();
+                Map<String, String> properties = eventConfigDTO.getProperties();
+                if (properties != null) {
+                    properties.forEach((key, value) -> {

-                EventProperty eventProperty = new EventProperty();
-                eventProperty.setPropertyKey(key);
-                eventProperty.setPropertyValue(value);
-                eventProperties.add(eventProperty);
-            });
+                        EventProperty eventProperty = new EventProperty();
+                        eventProperty.setPropertyKey(key);
+                        eventProperty.setPropertyValue(value);
+                        eventProperties.add(eventProperty);
+                    });
+                }

-            EventConfig eventConfig = new EventConfig();
-            eventConfig.setEventName(eventName);
-            eventConfig.setEnabled(eventConfigDTO.isEnabled());
-            eventConfig.setProperties(eventProperties);
-            eventConfigs.add(eventConfig);
-        });
+                EventConfig eventConfig = new EventConfig();
+                eventConfig.setEventName(eventName);
+                eventConfig.setEnabled(eventConfigDTO.isEnabled());
+                eventConfig.setProperties(eventProperties);
+                eventConfigs.add(eventConfig);
+            });
+        }

         fraudDetectionConfig.setEvents(eventConfigs);
         return fraudDetectionConfig;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private FraudDetectionConfig buildFraudDetectionConfig(FraudDetectionConfigDTO dto) {
FraudDetectionConfig fraudDetectionConfig = new FraudDetectionConfig();
fraudDetectionConfig.setPublishUserInfo(dto.isPublishUserInfo());
fraudDetectionConfig.setPublishDeviceMetadata(dto.isPublishDeviceMetadata());
fraudDetectionConfig.setLogRequestPayload(dto.isLogRequestPayload());
List<EventConfig> eventConfigs = new ArrayList<>();
dto.getEvents().forEach((eventName, eventConfigDTO) -> {
List<EventProperty> eventProperties = new ArrayList<>();
eventConfigDTO.getProperties().forEach((key, value) -> {
EventProperty eventProperty = new EventProperty();
eventProperty.setPropertyKey(key);
eventProperty.setPropertyValue(value);
eventProperties.add(eventProperty);
});
EventConfig eventConfig = new EventConfig();
eventConfig.setEventName(eventName);
eventConfig.setEnabled(eventConfigDTO.isEnabled());
eventConfig.setProperties(eventProperties);
eventConfigs.add(eventConfig);
});
fraudDetectionConfig.setEvents(eventConfigs);
return fraudDetectionConfig;
}
private FraudDetectionConfig buildFraudDetectionConfig(FraudDetectionConfigDTO dto) {
FraudDetectionConfig fraudDetectionConfig = new FraudDetectionConfig();
fraudDetectionConfig.setPublishUserInfo(dto.isPublishUserInfo());
fraudDetectionConfig.setPublishDeviceMetadata(dto.isPublishDeviceMetadata());
fraudDetectionConfig.setLogRequestPayload(dto.isLogRequestPayload());
List<EventConfig> eventConfigs = new ArrayList<>();
Map<String, EventConfigDTO> events = dto.getEvents();
if (events != null) {
events.forEach((eventName, eventConfigDTO) -> {
List<EventProperty> eventProperties = new ArrayList<>();
Map<String, String> properties = eventConfigDTO.getProperties();
if (properties != null) {
properties.forEach((key, value) -> {
EventProperty eventProperty = new EventProperty();
eventProperty.setPropertyKey(key);
eventProperty.setPropertyValue(value);
eventProperties.add(eventProperty);
});
}
EventConfig eventConfig = new EventConfig();
eventConfig.setEventName(eventName);
eventConfig.setEnabled(eventConfigDTO.isEnabled());
eventConfig.setProperties(eventProperties);
eventConfigs.add(eventConfig);
});
}
fraudDetectionConfig.setEvents(eventConfigs);
return fraudDetectionConfig;
}
🤖 Prompt for AI Agents
In
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java
around lines 2061 to 2089, the code calls forEach() on dto.getEvents() and
eventConfigDTO.getProperties() without null checks which can cause NPEs; before
iterating, defensively check if dto.getEvents() is null and treat it as an empty
collection (skip iteration if null), and inside the events loop check if
eventConfigDTO.getProperties() is null and treat it as empty (skip or use empty
map/list) so you only iterate when non-null, ensuring
fraudDetectionConfig.setEvents(...) still receives an empty list when there are
no events.

Comment on lines +2091 to +2113
private FraudDetectionConfigDTO buildFraudDetectionConfigDTO(FraudDetectionConfig config) {

FraudDetectionConfigDTO fraudDetectionConfigDTO = new FraudDetectionConfigDTO();
fraudDetectionConfigDTO.setPublishUserInfo(config.getPublishUserInfo());
fraudDetectionConfigDTO.setPublishDeviceMetadata(config.getPublishDeviceMetadata());
fraudDetectionConfigDTO.setLogRequestPayload(config.getLogRequestPayload());

Map<String, EventConfigDTO> eventConfigDTOMap = new HashMap<>();
config.getEvents().forEach(eventConfig -> {

Map<String, String> propertiesMap = new HashMap<>();
eventConfig.getProperties().forEach(eventProperty ->
propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));

EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
eventConfigDTO.setProperties(propertiesMap);
eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
});

fraudDetectionConfigDTO.setEvents(eventConfigDTOMap);

return fraudDetectionConfigDTO;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add null safety checks for collections.

Similar to buildFraudDetectionConfig(), this method calls forEach() on config.getEvents() (line 2099) and eventConfig.getProperties() (line 2102) without null checks.

🔎 Apply this diff to add defensive null checks:
     private FraudDetectionConfigDTO buildFraudDetectionConfigDTO(FraudDetectionConfig config) {

         FraudDetectionConfigDTO fraudDetectionConfigDTO = new FraudDetectionConfigDTO();
         fraudDetectionConfigDTO.setPublishUserInfo(config.getPublishUserInfo());
         fraudDetectionConfigDTO.setPublishDeviceMetadata(config.getPublishDeviceMetadata());
         fraudDetectionConfigDTO.setLogRequestPayload(config.getLogRequestPayload());

         Map<String, EventConfigDTO> eventConfigDTOMap = new HashMap<>();
-        config.getEvents().forEach(eventConfig -> {
+        List<EventConfig> events = config.getEvents();
+        if (events != null) {
+            events.forEach(eventConfig -> {

-            Map<String, String> propertiesMap = new HashMap<>();
-            eventConfig.getProperties().forEach(eventProperty ->
-                    propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));
+                Map<String, String> propertiesMap = new HashMap<>();
+                List<EventProperty> properties = eventConfig.getProperties();
+                if (properties != null) {
+                    properties.forEach(eventProperty ->
+                            propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));
+                }

-            EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
-            eventConfigDTO.setProperties(propertiesMap);
-            eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
-        });
+                EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
+                eventConfigDTO.setProperties(propertiesMap);
+                eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
+            });
+        }

         fraudDetectionConfigDTO.setEvents(eventConfigDTOMap);

         return fraudDetectionConfigDTO;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private FraudDetectionConfigDTO buildFraudDetectionConfigDTO(FraudDetectionConfig config) {
FraudDetectionConfigDTO fraudDetectionConfigDTO = new FraudDetectionConfigDTO();
fraudDetectionConfigDTO.setPublishUserInfo(config.getPublishUserInfo());
fraudDetectionConfigDTO.setPublishDeviceMetadata(config.getPublishDeviceMetadata());
fraudDetectionConfigDTO.setLogRequestPayload(config.getLogRequestPayload());
Map<String, EventConfigDTO> eventConfigDTOMap = new HashMap<>();
config.getEvents().forEach(eventConfig -> {
Map<String, String> propertiesMap = new HashMap<>();
eventConfig.getProperties().forEach(eventProperty ->
propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));
EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
eventConfigDTO.setProperties(propertiesMap);
eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
});
fraudDetectionConfigDTO.setEvents(eventConfigDTOMap);
return fraudDetectionConfigDTO;
}
private FraudDetectionConfigDTO buildFraudDetectionConfigDTO(FraudDetectionConfig config) {
FraudDetectionConfigDTO fraudDetectionConfigDTO = new FraudDetectionConfigDTO();
fraudDetectionConfigDTO.setPublishUserInfo(config.getPublishUserInfo());
fraudDetectionConfigDTO.setPublishDeviceMetadata(config.getPublishDeviceMetadata());
fraudDetectionConfigDTO.setLogRequestPayload(config.getLogRequestPayload());
Map<String, EventConfigDTO> eventConfigDTOMap = new HashMap<>();
List<EventConfig> events = config.getEvents();
if (events != null) {
events.forEach(eventConfig -> {
Map<String, String> propertiesMap = new HashMap<>();
List<EventProperty> properties = eventConfig.getProperties();
if (properties != null) {
properties.forEach(eventProperty ->
propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));
}
EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
eventConfigDTO.setProperties(propertiesMap);
eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
});
}
fraudDetectionConfigDTO.setEvents(eventConfigDTOMap);
return fraudDetectionConfigDTO;
}
🤖 Prompt for AI Agents
In
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java
around lines 2091 to 2113, add defensive null checks so we never call forEach on
a null collection: check config.getEvents() for null before iterating (or
iterate over Collections.emptyList() if null) and check
eventConfig.getProperties() for null before iterating (or treat as empty) so
propertiesMap and eventConfigDTOMap are only populated when collections exist;
ensure fraudDetectionConfigDTO.setEvents() still receives an empty map when
there are no events.

description: Update fraud detection related configuration of a tenant.
responses:
'202':
description: Successully updated.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in response description.

"Successully" should be "Successfully".

🔎 Apply this diff:
-          description: Successully updated.
+          description: Successfully updated.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: Successully updated.
description: Successfully updated.
🤖 Prompt for AI Agents
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml
around line 1168: the response description contains a typo "Successully
updated."; update the string to "Successfully updated." (fix the spelling only,
preserving punctuation and surrounding formatting).

@ZiyamSanthosh ZiyamSanthosh force-pushed the master-fraud-detection-configs-2 branch from 480be28 to c94cbae Compare December 18, 2025 08:46
Copy link

@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

♻️ Duplicate comments (5)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (1)

1160-1173: Unresolved: Response status code mismatch between spec and implementation.

The OpenAPI spec still defines the PUT operation to return 202 Accepted (line 1167), but according to previous review comments, the implementation returns 200 OK. This inconsistency remains unaddressed.

Please ensure both the specification and implementation use the same status code. If the operation is synchronous, both should use 200. If asynchronous or queued, both should use 202.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (4)

2034-2045: Catch the base exception type, not just server exceptions.

The catch block only handles FraudDetectionConfigServerException. If FraudDetectionConfigClientException is thrown (e.g., validation errors), it won't be caught, resulting in unhandled exceptions. Change the catch clause to catch IdentityFraudDetectionException (the base exception type) to handle both client and server exceptions uniformly.

🔎 Apply this diff to catch all fraud detection exceptions:
-        } catch (FraudDetectionConfigServerException e) {
+        } catch (IdentityFraudDetectionException e) {
             throw handleFraudDetectionConfigException(e,
                     Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE, null);
         }

2047-2059: Catch the base exception type, not just server exceptions.

Same issue as getFraudDetectionConfigs() - only FraudDetectionConfigServerException is caught, leaving client exceptions unhandled. Change the catch clause to catch IdentityFraudDetectionException to handle both client and server exceptions.

🔎 Apply this diff to catch all fraud detection exceptions:
-        } catch (FraudDetectionConfigServerException e) {
+        } catch (IdentityFraudDetectionException e) {
             throw handleFraudDetectionConfigException(e,
                     Constants.ErrorMessage.ERROR_CODE_FRAUD_DETECTION_CONFIG_UPDATE, null);
         }

2061-2089: Add null safety checks for collections.

The method calls forEach() on dto.getEvents() (line 2069) and eventConfigDTO.getProperties() (line 2072) without null checks, which will throw NPE if these collections are null. Add defensive null checks before iterating over these collections.

🔎 Apply this diff to add defensive null checks:
     private FraudDetectionConfig buildFraudDetectionConfig(FraudDetectionConfigDTO dto) {

         FraudDetectionConfig fraudDetectionConfig = new FraudDetectionConfig();
         fraudDetectionConfig.setPublishUserInfo(dto.isPublishUserInfo());
         fraudDetectionConfig.setPublishDeviceMetadata(dto.isPublishDeviceMetadata());
         fraudDetectionConfig.setLogRequestPayload(dto.isLogRequestPayload());

         List<EventConfig> eventConfigs = new ArrayList<>();
-        dto.getEvents().forEach((eventName, eventConfigDTO) -> {
+        Map<String, EventConfigDTO> events = dto.getEvents();
+        if (events != null) {
+            events.forEach((eventName, eventConfigDTO) -> {

-            List<EventProperty> eventProperties = new ArrayList<>();
-            eventConfigDTO.getProperties().forEach((key, value) -> {
+                List<EventProperty> eventProperties = new ArrayList<>();
+                Map<String, String> properties = eventConfigDTO.getProperties();
+                if (properties != null) {
+                    properties.forEach((key, value) -> {

-                EventProperty eventProperty = new EventProperty();
-                eventProperty.setPropertyKey(key);
-                eventProperty.setPropertyValue(value);
-                eventProperties.add(eventProperty);
-            });
+                        EventProperty eventProperty = new EventProperty();
+                        eventProperty.setPropertyKey(key);
+                        eventProperty.setPropertyValue(value);
+                        eventProperties.add(eventProperty);
+                    });
+                }

-            EventConfig eventConfig = new EventConfig();
-            eventConfig.setEventName(eventName);
-            eventConfig.setEnabled(eventConfigDTO.isEnabled());
-            eventConfig.setProperties(eventProperties);
-            eventConfigs.add(eventConfig);
-        });
+                EventConfig eventConfig = new EventConfig();
+                eventConfig.setEventName(eventName);
+                eventConfig.setEnabled(eventConfigDTO.isEnabled());
+                eventConfig.setProperties(eventProperties);
+                eventConfigs.add(eventConfig);
+            });
+        }

         fraudDetectionConfig.setEvents(eventConfigs);
         return fraudDetectionConfig;
     }

2091-2113: Add null safety checks for collections.

Similar to buildFraudDetectionConfig(), this method calls forEach() on config.getEvents() (line 2099) and eventConfig.getProperties() (line 2102) without null checks. Add defensive null checks to prevent NPEs when collections are null.

🔎 Apply this diff to add defensive null checks:
     private FraudDetectionConfigDTO buildFraudDetectionConfigDTO(FraudDetectionConfig config) {

         FraudDetectionConfigDTO fraudDetectionConfigDTO = new FraudDetectionConfigDTO();
         fraudDetectionConfigDTO.setPublishUserInfo(config.getPublishUserInfo());
         fraudDetectionConfigDTO.setPublishDeviceMetadata(config.getPublishDeviceMetadata());
         fraudDetectionConfigDTO.setLogRequestPayload(config.getLogRequestPayload());

         Map<String, EventConfigDTO> eventConfigDTOMap = new HashMap<>();
-        config.getEvents().forEach(eventConfig -> {
+        List<EventConfig> events = config.getEvents();
+        if (events != null) {
+            events.forEach(eventConfig -> {

-            Map<String, String> propertiesMap = new HashMap<>();
-            eventConfig.getProperties().forEach(eventProperty ->
-                    propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));
+                Map<String, String> propertiesMap = new HashMap<>();
+                List<EventProperty> properties = eventConfig.getProperties();
+                if (properties != null) {
+                    properties.forEach(eventProperty ->
+                            propertiesMap.put(eventProperty.getPropertyKey(), eventProperty.getPropertyValue()));
+                }

-            EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
-            eventConfigDTO.setProperties(propertiesMap);
-            eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
-        });
+                EventConfigDTO eventConfigDTO = new EventConfigDTO(eventConfig.getEnabled());
+                eventConfigDTO.setProperties(propertiesMap);
+                eventConfigDTOMap.put(eventConfig.getEventName(), eventConfigDTO);
+            });
+        }

         fraudDetectionConfigDTO.setEvents(eventConfigDTOMap);

         return fraudDetectionConfigDTO;
     }
🧹 Nitpick comments (2)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java (1)

213-218: Consider whether tenant context should be included in error descriptions.

The fraud detection error descriptions don't include a placeholder for tenant domain or organization context, unlike similar configuration errors (e.g., impersonation errors at lines 197-202, 209-211). If fraud detection configurations are tenant-specific, consider adding contextual information to the error descriptions for consistency and improved debugging.

Example with tenant context:
-        ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE("65023",
-                "Unable to retrieve Fraud Detection configuration.",
-                "Server encountered an error while retrieving the Fraud Detection configuration."),
+        ERROR_CODE_FRAUD_DETECTION_CONFIG_RETRIEVE("65023",
+                "Unable to retrieve Fraud Detection configuration.",
+                "Server encountered an error while retrieving the Fraud Detection configuration of %s."),
-        ERROR_CODE_FRAUD_DETECTION_CONFIG_UPDATE("65024",
-                "Unable to update Fraud Detection configuration.",
-                "Server encountered an error while updating the Fraud Detection configuration.");
+        ERROR_CODE_FRAUD_DETECTION_CONFIG_UPDATE("65024",
+                "Unable to update Fraud Detection configuration.",
+                "Server encountered an error while updating the Fraud Detection configuration of %s.");
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (1)

1586-1630: Consider specifying required fields for schema validation.

None of the fraud detection schemas define required fields. This means all properties are optional by default, which may lead to incomplete or ambiguous data being accepted by the API.

Consider marking essential fields as required:

  • In EventConfig, eventName should likely be required to identify which event is being configured.
  • In EventProperty, both propertyKey and propertyValue should likely be required when a property object is provided.
🔎 Example of adding required constraints:
 EventConfig:
   type: object
+  required:
+    - eventName
   properties:
     eventName:
 EventProperty:
   type: object
+  required:
+    - propertyKey
+    - propertyValue
   properties:
     propertyKey:
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 480be28 and c94cbae.

⛔ Files ignored due to path filters (5)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/ConfigsApi.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/ConfigsApiService.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventConfig.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventProperty.java is excluded by !**/gen/**
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java is excluded by !**/gen/**
📒 Files selected for processing (9)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml (1 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (7 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (3 hunks)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml (2 hunks)
  • pom.xml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml
  • pom.xml
  • components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/factories/ServerConfigManagementServiceFactory.java
🧰 Additional context used
🧬 Code graph analysis (2)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (1)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java (1)
  • FraudDetectionConfig (36-175)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (3)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventConfig.java (1)
  • EventConfig (36-153)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/EventProperty.java (1)
  • EventProperty (33-120)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/FraudDetectionConfig.java (1)
  • FraudDetectionConfig (36-175)
🔇 Additional comments (10)
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/Constants.java (1)

211-218: LGTM! Duplicate error code issue resolved.

The error codes have been updated to "65023" and "65024", which are unique and maintain the sequential numbering pattern. This resolves the critical duplicate error code issue flagged in the previous review.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml (1)

188-192: Verify version management and dependency availability.

The new fraud detection dependency is correctly scoped as provided, but ensure the following:

  1. The version for org.wso2.carbon.identity.fraud.detection.core is properly defined in the parent POM's <dependencyManagement> section.
  2. The artifact exists in the configured Maven repositories.
  3. The version is compatible with other org.wso2.carbon.identity.framework dependencies in use.

Run the following script to verify version management in the parent POM:

#!/bin/bash
# Description: Verify that the fraud detection dependency version is managed in parent POMs

# Check root pom.xml for version management
echo "=== Checking root pom.xml for fraud detection dependency version ==="
rg -A 3 "org.wso2.carbon.identity.fraud.detection.core" pom.xml

# Check parent module pom.xml
echo -e "\n=== Checking parent configs module pom.xml ==="
rg -A 3 "org.wso2.carbon.identity.fraud.detection.core" components/org.wso2.carbon.identity.api.server.configs/pom.xml

# Verify other identity.framework dependency versions for compatibility
echo -e "\n=== Checking other identity.framework dependency versions ==="
rg -n "org.wso2.carbon.identity.framework" pom.xml | head -20
components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java (3)

51-53: LGTM!

The new imports for fraud detection models, exceptions, DTOs, and the HashMap utility are correctly added to support the fraud detection configuration feature.

Also applies to: 95-100, 127-127


153-153: LGTM!

The FraudDetectionConfigsService is properly wired through constructor dependency injection, following the same pattern as other services in this class.

Also applies to: 169-170, 179-179


2115-2152: LGTM!

The exception handler correctly differentiates between client and server exceptions, maps them to appropriate HTTP status codes, and follows the same pattern as other exception handlers in this class.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/src/main/java/org/wso2/carbon/identity/api/server/configs/common/ConfigsServiceHolder.java (2)

26-26: LGTM! Import follows WSO2 package conventions.

The import statement is correct and consistent with other service imports in the file.


98-103: Implementation follows the established service holder pattern correctly.

The FraudDetectionConfigsServiceHolder and its getter method match the pattern used by all other services in this file. Null handling is properly managed at the consumer level—the ServerConfigManagementServiceFactory validates FraudDetectionConfigsService availability and throws IllegalStateException if unavailable, consistent with all other required services.

components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/impl/ConfigsApiServiceImpl.java (3)

26-26: LGTM: Import statement is appropriate.

The import is necessary for the new fraud detection configuration endpoints.


135-139: Add null checking for fraud detection configs retrieval.

The getFraudDetectionConfigs() method directly passes the service result to buildFraudDetectionConfig() without null checking. If fraudDetectionConfigsService.getFraudDetectionConfigs() returns null, the code will throw a NullPointerException when buildFraudDetectionConfig() attempts to call methods on the null DTO (e.g., dto.isPublishUserInfo()).

Follow the pattern used in getRemoteLoggingConfig() (lines 114-123): check if the result is null and return a 404 response, or ensure the service layer always returns a valid object with defaults.


230-234: Return pattern for updateFraudDetectionConfigs is justified—the service enriches the configuration during update.

The method returns the updated entity, which differs from other update methods (updateInboundScimConfigs, updateRemoteLoggingConfig, updateSAMLInboundAuthConfig, updatePassiveSTSInboundAuthConfig). However, this is intentional: the service layer transforms the input through DTO conversion (buildFraudDetectionConfigDTO → service call → buildFraudDetectionConfig), enriching the configuration before returning it. Returning the entity allows clients to see the final state with any server-applied transformations or defaults. This pattern is consistent with RESTful practices for resources that undergo server-side enrichment.

@ZiyamSanthosh ZiyamSanthosh force-pushed the master-fraud-detection-configs-2 branch from c94cbae to df0b0bb Compare December 19, 2025 06:24
@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/20367260184

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/20367260184
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/20367260184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants