9

If you have this testmethod:

@IsTest
private class NewSysadTest {
  @IsTest
  static void testSuccess() {
    User testUser =   new User(
        username=UserInfo.getUserId()+'.'+ (DateTime.now()+':'+Math.random()).HashCode()+
                 '@'+UserInfo.getOrganizationId()+'.sfdcOrg',
        alias = 'testExec',
        email='apextests@example.com',
        emailencodingkey='UTF-8',
        lastname='Testing',
        languagelocalekey='en_US',
        localesidkey='en_US',
        profileId = [SELECT Id FROM Profile WHERE Name = 'System Administrator'].Id,
        timezonesidkey='America/Los_Angeles'
    );
    insert testUser;
    PermissionSetAssignment psa = new PermissionSetAssignment(
        AssigneeId = testUser.Id,
        PermissionSetId = [SELECT Id FROM PermissionSet 
                             WHERE Name = 'somePermissionSetName'][0].Id);
    insert psa;  // gack here
  }
}
  • In Spring 22, you will get a GACK 25028890-5216755 (324258501) (324258501) on the insert of the PermissionSetAssignment; GACK occurs as well if wrapped in System.runAs
  • In Winter 22, it runs fine

Case filed with SFDC Support

11
  • 1
    Public reference can't hurt.
    – Adrian Larson
    Jan 10 at 19:52
  • 3
    dev internal folks can search with it as well to find linked work/known issues so you never know if someone will do so. Otherwise, it might help someone find this post. Speaking of which, if you need to unblock yourself - it seems setting UserPermissionsKnowledgeUser = true for the user should allow the test to pass. I could have this wrong, but It seems to be throwing an access error on a specific knowledge permission on the permissionset. Support can hopefully get more action/info on what's going on and what the best course of action is (need a patch, org permission, etc). Jan 10 at 20:19
  • 1
    I'm glad you had a MVR as I was easily able to reproduce it (and see it pass afterwards). I'm internal now (so no magical powers), but I can see a bit more behind the scenes with these types of issues. Support can get back to you on a more official response - there could be more at play happening. Jan 10 at 20:39
  • 2
    @cropredy Can you also share the Case number please. Jan 11 at 16:20
  • 2
    I see case number @cropredy logged is #41891331.Will keep an eye on the case. This issue was reported by several other customers too and we have a bug logged for it internally #W-10419259 and Inv #W-10414023. Will keep you posted on the progress
    – Swetha
    Jan 12 at 8:50

1 Answer 1

10

Fixed - This will be handled by Spring '22 Patch 4.6.


Update: There is now a Known Issue - Test classes are failing with Salesforce Internal Server Error. The workaround listed is to update the versions of the classes to 54.


I work for Salesforce, not on the team related to this, so the below is only based on my analysis of what I see based on the stacktrace/gack).

For now, you can add the Knowledge permission to the User in your test to avoid hitting the error (so your builds/checks will pass).

User testUser = new User(...,
UserPermissionsKnowledgeUser = true,
...

Internally, the gack/stacktrace is related to not finding/existing a permission (specifically, related to Knowledge) when looking at the permissions on the PermissionSet. As that's not something under your control, I presume it shouldn't be doing this (considering it passed previously). The workaround above gets around that since the User will have access to Knowledge and thus that permission is exposed/available to be queried/checked.

Support will be able to get a concrete answer and a course of action on what will/should happen. Again, this is not official, but I would venture a guess a patch will fix this so you do not need the workaround above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.