beyond-the-cloud-dev / soql-lib

The SOQL Lib provides functional constructs for SOQL queries in Apex.
https://soql.beyondthecloud.dev/
MIT License
61 stars 9 forks source link

stripInaccessibleToObject, stripInaccessibleToList unit tests fail in v3.2.0 #103

Closed sjurgis closed 7 months ago

sjurgis commented 7 months ago

After upgrading from older version (previous version unknown, but older than v2.2.0) I am getting:

System.NullPointerException: Attempt to de-reference a null object
Class.SOQL_Test.stripInaccessibleToList: line 2080, column 1

I presume because expected exception wasn't throw. Spring '24 Patch 9.1 Unlimited Edition

In previous version I can see

            if (queryException != null) {

So perhaps someone modified our copy the lib beforehand...

pgajek2 commented 7 months ago

Hi @sjurgis,

I checked older versions of SOQL Lib (starting from v2.2.0 and older), and there is no if (queryException != null), so probably someone updated your copy, and I even know why! 👯

Explanation

The SOQL_Test.stripInaccessibleToList method is executed in a standard user context. By default Standard User Profile has no access to the Task.Type field. I assume that access to the Task.Type field on your org was granted, and that is fine.

image

Solution

The Standard User Profile on your org has access to the Task.Type field, but we need Profile with no access to Task.Type so stripInaccessibleToList will be executed successfully.

I updated SOQL Lib, so instead of Standard User Profile we use Minimum Access - Salesforce. It should resolve the problem.

Next Step

Please update your SOQL Lib with code from the main branch (SOQL.cls and SOQL_Test.cls) and let me know if it works as expected.

sjurgis commented 7 months ago

Thanks, seems working!