@AuraEnabled property cannot be read by the component
ID |
apex.correctness.inaccessible_aura_getter |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Api Usage |
Language |
Apex |
Description
Reports an @AuraEnabled property that is itself private or protected, whose getter is private or protected, or that declares no getter at all.
Rationale
The annotation only says the property is part of the component contract; the framework still has to call the getter to serialize the value, and it cannot call one it is not allowed to see. The class compiles, the deployment succeeds, and the component receives the property as undefined - so the failure surfaces in the browser as an empty field or a JavaScript error about reading a property of undefined, with nothing at all in the Apex debug log to connect it back to this line.
The following code illustrates the pattern detected by this rule:
public class InvoiceWrapper {
// FLAGGED: @AuraEnabled property cannot be read by the component
@AuraEnabled
public Decimal totalAmount { private get; set; }
// FLAGGED: @AuraEnabled property cannot be read by the component
@AuraEnabled
private String customerName { get; set; }
// FLAGGED: @AuraEnabled property cannot be read by the component
@AuraEnabled
public String status { set; }
@AuraEnabled
public Decimal taxAmount { get; set; }
@AuraEnabled
public String invoiceNumber { get; private set; }
public Decimal internalMargin { private get; set; }
}