[SalesForce] Salesforce Internal Error when executing Apex Immediate Action in Process Builder

Referenced Class

public class InvocableSample{

    @InvocableMethod
    public static void invoke(List<Account> accounts){
        System.debug(accounts);
    }
}

Steps to Reproduce

  1. Create an Account Process

    a. Start the process = 'when a record is created or edited'

    b. Allow process to evaluate a record multiple times in a single transaction? = 'Yes' or 'No' (both produce the same error)

  2. Define Criteria for this Action Group

    a. Criteria for Executing Actions = 'No criteria-just execute the actions!'

  3. Create an Immediate Action

    a. Apex Class = InvocableSample

    b. Variable = 'accounts'

    c. Value = '[Account]'

  4. Execute Anonymous Apex:

    List<Account> accounts = [SELECT Id FROM Account LIMIT 2];
    update accounts;
    

Exception Thrown

12:21:53:793 EXCEPTION_THROWN [3]|System.DmlException: Update failed. First exception on row 0 with id 001A0000009uZGUIA2; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. <br>java.lang.IndexOutOfBoundsException: Index: 1, Size: 1<br>Index: 1, Size: 1 <br/> Contact your administrator for help.: []

Fatal Error

12:21:53:795 FATAL_ERROR Internal Salesforce.com Error

Environment

cs9

*Adjusting the Anonymous Apex SOQL to 'LIMIT 1' results in successful execution, no error.

Best Answer

Workaround is to return a list even if the list isn't being used, according to known issues, will be fixed in Summer 15 release.