@AuraEnabled member is not public or global

ID

apex.correctness.auraenabled_visibility

Severity

high

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Api Design

Language

Apex

Description

Reports a method annotated @AuraEnabled that is declared private or protected.

Rationale

The Lightning framework calls the member from outside the class, so anything narrower than public cannot be reached. The annotation makes the code look wired up, the component compiles, and the failure only appears at runtime as an empty result or an error in the browser - typically in a sandbox demo rather than in the pipeline, because no Apex test exercises the component’s call path.

The following code illustrates the pattern detected by this rule:

public with sharing class AccountController {

    // FLAGGED: @AuraEnabled member is not public or global
    @AuraEnabled
    private static List<Account> loadAccounts() {
        return [SELECT Id, Name FROM Account];
    }

    // FLAGGED: @AuraEnabled member is not public or global
    @AuraEnabled(cacheable=true)
    private static Integer countAccounts() {
        return 0;
    }

    @AuraEnabled
    public static List<Account> loadAccountsPublic() {
        return [SELECT Id, Name FROM Account];
    }

    @AuraEnabled(cacheable=true)
    public static Integer countAccountsPublic() {
        return 0;
    }
}

Remediation

Declare the member public, or global where the component lives in another namespace. For a wrapper class returned to the component, every property the component reads needs @AuraEnabled and public as well.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved