OrgReady

Salesforce Skills & Readiness

Back to Apex Development

Guided practice · Apex Development

AI & AgentforceDebuggingHard

Guided Practice Challenge

Review AI-Generated Apex, LWC, and Flow Changes

Review AI-Generated Apex, LWC, and Flow Changes.

Challenge

Version 1

Inspect the evidence

Artifact / implementation

Review the supplied code, configuration or trace before proposing a fix.

SYNTHETIC REVIEW PACKET: intentionally defective excerpts, not deployable files.
Requirements: agents may close only Cases they are authorized to update;
customer-visible fields must not be exposed unintentionally; bulk input is supported.
Supplied manifest: Apex API version 66.0. The only exported Apex method is
CaseCloseService.closeCases. No method named closeCaseBatch exists in this exercise.

APEX EXCERPT (API 66.0):
public without sharing class CaseCloseService {
    @AuraEnabled
    public static void closeCases(List<Id> caseIds) {
        for (Id caseId : caseIds) {
            Case c = [SELECT Id, Status FROM Case WHERE Id = :caseId];
            c.Status = 'Closed';
            update c;
        }
    }
}

LWC EXCERPT:
import closeCases from '@salesforce/apex/CaseCloseService.closeCaseBatch';
// A hidden UI button is the only client-side permission control.
await closeCases({ caseIds: selectedIds });

FLOW DESIGN SKETCH (not Flow XML):
API 66.0 autolaunched flow is configured for system context without sharing.
Input: collection of Case IDs from the caller.
For each ID: set Case.Status = Closed directly, without eligibility validation.
Apex and Flow implement separate close rules; neither checks approved transitions.

TEST SKETCH (not a complete Apex test):
Create one Case as an administrator; invoke the method; assert true.
No restricted-user, bulk, invalid-ID, or Flow/LWC integration tests.

RELEASE PROPOSAL (text only):
Deploy directly because the patch was AI-generated and the one test passed.
Skip static analysis, validation deployment, and human review.

Response workspace

Identify the issue, explain why it is a problem, and describe the fix. Include both your analysis and corrected solution below.

0 analysis characters

0 solution characters