forcedotcom / sfdx-scanner

MIT License
209 stars 49 forks source link

[BUG] InternalExecutionError on method with param of custom apex object type #1410

Closed jaelee125 closed 3 months ago

jaelee125 commented 4 months ago

Example Code:

SN_MetadataWrappers.LikeItemFinderSettingWrapper wrapper = (SN_MetadataWrappers.LikeItemFinderSettingWrapper)SN_MetadataWrappers.parseSingleMetadataWrapper(setting); SN_SettingsUtils.deleteLikeItemFinderSetting(wrapper);

SN_SettingsUtils class public static void deleteLikeItemFinderSetting(SN_MetadataWrappers.LikeItemFinderSettingWrapper wrapper) {

}

Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Then, add an engine directive to skip the path. Next, create a Github issue for the Code Analyzer team that includes the error and stack trace. After we fix this issue, check the Code Analyzer release notes for more info. Error and stacktrace: UnexpectedException: Did not expect NOT_A_MATCH when ranking parameter match. parameterType = SN_MetadataWrappers.LikeItemFinderSettingWrapper, type = OrderedTreeSet{internalList=[NULL, Object]}: com.salesforce.graph.ops.TypeableUtil.rankParameterMatch(TypeableUtil.java:211);com.salesforce.graph.vertex.Typeable.rankParameterMatch(Typeable.java:41);com.salesforce.graph.ops.MethodTypeMatchUtil.getMatchRank(MethodTypeMatchUtil.java:191);com.salesforce.graph.ops.MethodTypeMatchUtil.parameterTypesMatch(MethodTypeMatchUtil.java:128);com.salesforce.graph.ops.MethodUtil.getInvoked(MethodUtil.java:358);com.salesforce.graph.ops.MethodUtil.getInvoked(MethodUtil.java:158)

nwcm commented 3 months ago

Also seeing this issue. Related to class constructors with custom types

public inherited sharing class FooClass {

  public FooClass(Custom__c obj){

  }

}
public inherited sharing class CallingClass {

  public static void callMethod(){
    FooClass(new Custom__c());
  }

}

There is a not very nice work around:

public inherited sharing class FooClass {
  private Custom__c obj;

  public FooClass(Object obj){
    this.obj = obj;
  }

}
nwcm commented 3 months ago

After further testing, you can also work around by specifying the custom type in the param.

public inherited sharing class FooClass {

  public FooClass(Custom__c obj){

  }

}
public inherited sharing class CallingClass {

  public static void callMethod(){
    FooClass((Custom__c) new Custom__c());
  }

}
sagar-j-sfdc commented 3 months ago

This is a duplicate of #1195