Skip to content

Conversation

@PasinduYeshan
Copy link
Contributor

@PasinduYeshan PasinduYeshan commented Oct 3, 2025

Purpose

$subject

Related Issues

Related PRs

TID: [-1234] [2025-10-03 16:38:33,678] [5ce8fb2d-3ad5-42f1-8fcf-41661288f6ea]  INFO {AUDIT_LOG} - {"id":"ac1327d6-16a8-41df-86eb-b1c96ca3295c","recordedAt":"2025-10-03T11:08:33.659615Z","requestId":"5ce8fb2d-3ad5-42f1-8fcf-41661288f6ea","initiatorId":"cd0aa5bc-6103-42cc-b7ad-cb02d506af4d","initiatorType":"User","targetId":"2d87ba6e-4040-4a0e-b7e0-4c64cddd3b7c","targetType":"ApprovalTask","action":"approve-approval","data":{"TaskNewStatus":"APPROVED","TaskId":"2d87ba6e-4040-4a0e-b7e0-4c64cddd3b7c","StepValue":1,"WorkflowId":"0561a3d1-cb1e-489b-b010-75ba57d79d76","WorkflowRequestId":"50ae027d-2276-4a0a-934e-4361c747d9e4"}}

TID: [-1234] [2025-10-03 16:38:45,884] [c18a2e67-42b2-4a55-96d1-194d5514d5b8]  INFO {AUDIT_LOG} - {"id":"145448d8-e33a-4ffa-ace3-d75583cfa6fc","recordedAt":"2025-10-03T11:08:45.881457Z","requestId":"c18a2e67-42b2-4a55-96d1-194d5514d5b8","initiatorId":"cd0aa5bc-6103-42cc-b7ad-cb02d506af4d","initiatorType":"User","targetId":"95601980-1d7c-4bf3-ac3b-7c8249a549c7","targetType":"ApprovalTask","action":"reserve-approval","data":{"ApproverType":"claimedUsers","TaskId":"95601980-1d7c-4bf3-ac3b-7c8249a549c7","ApproverId":"cd0aa5bc-6103-42cc-b7ad-cb02d506af4d","TaskNewStatus":"RESERVED","WorkflowId":"0561a3d1-cb1e-489b-b010-75ba57d79d76","WorkflowRequestId":"2e393a13-6c79-46e1-811d-6033a19c1a42"}}

TID: [-1234] [2025-10-03 16:38:45,890] [c18a2e67-42b2-4a55-96d1-194d5514d5b8]  INFO {AUDIT_LOG} - {"id":"fa950098-9b01-4d82-8eec-4c27baf60f16","recordedAt":"2025-10-03T11:08:45.889894Z","requestId":"c18a2e67-42b2-4a55-96d1-194d5514d5b8","initiatorId":"cd0aa5bc-6103-42cc-b7ad-cb02d506af4d","initiatorType":"User","targetId":"95601980-1d7c-4bf3-ac3b-7c8249a549c7","targetType":"ApprovalTask","action":"reserve-approval","data":{"ApproverId":"cd0aa5bc-6103-42cc-b7ad-cb02d506af4d","TaskNewStatus":"BLOCKED","TaskId":"95601980-1d7c-4bf3-ac3b-7c8249a549c7","WorkflowId":"0561a3d1-cb1e-489b-b010-75ba57d79d76","WorkflowRequestId":"2e393a13-6c79-46e1-811d-6033a19c1a42"}}

Todo:

  • Bump framework version.

String workflowRequestId = approvalTaskDAO.getWorkflowRequestIdByApprovalTaskId(approvalTaskId);
String workflowId = approvalTaskDAO.getWorkflowID(approvalTaskId);

handleApprovalTaskCompletion(approvalTaskId, workflowRequestId, ApprovalTaskServiceImpl.APPROVED);

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
handleApprovalTaskCompletion(approvalTaskId, workflowRequestId, ApprovalTaskServiceImpl.APPROVED);
handleApprovalTaskCompletion(approvalTaskId, workflowRequestId, ApprovalTaskServiceImpl.APPROVED);
log.info("Approval task completed. TaskId: " + approvalTaskId + ", WorkflowRequestId: " + workflowRequestId);

.workflowRequestId(workflowRequestId)
.newStatus(WorkflowEngineConstants.TaskStatus.REJECTED.toString());
auditLogger.printAuditLog(auditBuilder);

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
completeWorkflowRequest(workflowRequestId, REJECTED);
log.info("Workflow request rejected and completed. WorkflowRequestId: " + workflowRequestId);


for (String existingApprovalTaskId : existingApprovalTasks) {
if (existingApprovalTaskId.equals(updatedApprovalTaskId)) {
if (WorkflowEngineConstants.APPROVER_TYPE_USERS.equals(approverType)) {

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 8

Suggested change
if (WorkflowEngineConstants.APPROVER_TYPE_USERS.equals(approverType)) {
if (WorkflowEngineConstants.APPROVER_TYPE_USERS.equals(approverType)) {
log.debug("Claiming task for user approver type. TaskId: " + updatedApprovalTaskId);

.workflowId(workflowId)
.newStatus(reservedStatus);
auditLogger.printAuditLog(auditBuilder);
} else if (WorkflowEngineConstants.APPROVER_TYPE_ROLES.equals(approverType)) {

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 9

Suggested change
} else if (WorkflowEngineConstants.APPROVER_TYPE_ROLES.equals(approverType)) {
} else if (WorkflowEngineConstants.APPROVER_TYPE_ROLES.equals(approverType)) {
log.debug("Claiming task for role approver type. TaskId: " + updatedApprovalTaskId);

.workflowId(workflowId)
.newStatus(blockedStatus);
auditLogger.printAuditLog(blockedApprovalBuilder);
}

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 10

Suggested change
}
} else {
log.debug("Blocking all existing tasks for workflow request: " + workflowRequestID);

Comment on lines +51 to +60
*/
public void triggerAuditLog(Operation operation, String targetId, Map<String, Object> dataMap) {

if (operation == null) {
log.warn("Operation is null. Cannot trigger audit log.");
return;
}
if (StringUtils.isBlank(targetId)) {
log.warn("Target ID is blank. Cannot trigger audit log.");
return;

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 11

Suggested change
*/
public void triggerAuditLog(Operation operation, String targetId, Map<String, Object> dataMap) {
if (operation == null) {
log.warn("Operation is null. Cannot trigger audit log.");
return;
}
if (StringUtils.isBlank(targetId)) {
log.warn("Target ID is blank. Cannot trigger audit log.");
return;
public void triggerAuditLog(Operation operation, String targetId, Map<String, Object> dataMap) {
if (operation == null) {
log.warn("Operation is null. Cannot trigger audit log.");
return;
}
if (StringUtils.isBlank(targetId)) {
log.warn("Target ID is blank. Cannot trigger audit log.");
return;
}
if (log.isDebugEnabled()) {
log.debug("Triggering audit log for operation: " + operation.getLogAction() + ", targetId: " + targetId);
}

LoggerUtils.getInitiatorType(initiatorId),
targetId,
LoggerUtils.Target.ApprovalTask.name(),
operation.getLogAction()).

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 12

Suggested change
operation.getLogAction()).
LoggerUtils.triggerAuditLogEvent(auditLogBuilder);
if (log.isDebugEnabled()) {
log.debug("Audit log triggered successfully for operation: " + operation.getLogAction());
}

Comment on lines +92 to +93
*
* @return Initiator id despite masking.

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 13

Suggested change
*
* @return Initiator id despite masking.
private String getInitiatorId() {
if (log.isDebugEnabled()) {
log.debug("Getting initiator ID for audit log");
}

if (!isV2AuditLogsEnabled()) {
if (log.isDebugEnabled()) {
log.debug("V2 audit logs are disabled. Skipping audit log for operation: " +
(builder.operation != null ? builder.operation.getLogAction() : "unknown"));

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 14

Suggested change
(builder.operation != null ? builder.operation.getLogAction() : "unknown"));
Map<String, Object> dataMap = builder.buildDataMap();
if (log.isDebugEnabled()) {
log.debug("Printing audit log for task: " + builder.taskId + ", operation: " + builder.operation.getLogAction());
}

Comment on lines +352 to +353
/**
* Validate required fields.

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 15

Suggested change
/**
* Validate required fields.
private void validate() {
if (log.isDebugEnabled()) {
log.debug("Validating audit log builder data");
}

Comment on lines +355 to +357
* @throws IllegalArgumentException if validation fails
*/
private void validate() {

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 16

Suggested change
* @throws IllegalArgumentException if validation fails
*/
private void validate() {
if (operation == null) {
log.error("Failed to validate audit log builder: Operation is required");
throw new IllegalArgumentException("Operation is required for audit logging");
}

Comment on lines +358 to +360

if (operation == null) {
throw new IllegalArgumentException("Operation is required for audit logging");

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 17

Suggested change
if (operation == null) {
throw new IllegalArgumentException("Operation is required for audit logging");
if (StringUtils.isBlank(taskId)) {
log.error("Failed to validate audit log builder: Task ID is required");
throw new IllegalArgumentException("Task ID is required for audit logging");
}

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: 2
#### Log Improvement Suggestion No: 6
#### Log Improvement Suggestion No: 8
#### Log Improvement Suggestion No: 9
#### Log Improvement Suggestion No: 10
#### Log Improvement Suggestion No: 11
#### Log Improvement Suggestion No: 12
#### Log Improvement Suggestion No: 13
#### Log Improvement Suggestion No: 14
#### Log Improvement Suggestion No: 15
#### Log Improvement Suggestion No: 16
#### Log Improvement Suggestion No: 17

@PasinduYeshan
Copy link
Contributor Author

@PasinduYeshan
Copy link
Contributor Author

image

@PasinduYeshan PasinduYeshan merged commit 1e03680 into wso2-extensions:main Oct 4, 2025
2 checks passed
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.

2 participants