NPE when searching for issues with rules filter

Hello,

I’m trying to implement a custom rule. I can see it in UI, I can attach it to quality profiles (it yet does not detect issues), but when I try to use the rule filter in issue search page, I’m getting a NPE.

2024.05.23 10:57:30 ERROR web[a563e482-01da-44c3-b766-0be3d4e1281e][o.s.s.w.WebServiceEngine] Fail to process request http://localhost:9000/api/issues/search?s=FILE_LINE&issueStatuses=CONFIRMED%2COPEN&ps=1&facets=rules&additionalFields=_all&timeZone=Europe%2FAmsterdam
java.lang.NullPointerException: Cannot invoke "org.sonar.api.rule.RuleKey.toString()" because the return value of "java.util.Map.get(Object)" is null
	at org.sonar.server.issue.ws.SearchResponseFormat.lambda$computeRulesFacet$12(SearchResponseFormat.java:473)
	at java.base/java.util.LinkedHashMap.forEach(Unknown Source)
	at org.sonar.server.issue.ws.SearchResponseFormat.computeRulesFacet(SearchResponseFormat.java:472)
	at org.sonar.server.issue.ws.SearchResponseFormat.formatFacets(SearchResponseFormat.java:409)
	at org.sonar.server.issue.ws.SearchResponseFormat.formatSearch(SearchResponseFormat.java:110)
	at org.sonar.server.issue.ws.SearchAction.doHandle(SearchAction.java:540)
	at org.sonar.server.issue.ws.SearchAction.handle(SearchAction.java:497)
	at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:114)

It It seems something is missing in my rule configs. Any clues are appreciated. Let me know if you need any specific details about the rule. Below is the rule json and a part of the rule class.

{
  "title": "MyCustomRule: My error description",
  "type": "BUG",
  "code": {
    "impacts": {
      "RELIABILITY": "MEDIUM"
    },
    "attribute": "LOGICAL"
  },
  "status": "ready",
  "remediation": {
    "func": "Constant\/Issue",
    "constantCost": "10min"
  },
  "tags": [
    "cwe",
    "cert",
    "symbolic-execution"
  ],
  "defaultSeverity": "Major",
  "ruleSpecification": "RSPEC-2259",
  "sqKey": "MyCustomRule",
  "scope": "Main",
  "quickfix": "unknown"
}

@Rule(key = "MyCustomRule")
public class MyCustomRule extends SECheck {

Hi,

Welcome to the community!

What SonarQube version are we talking about? And what language?

 
Thx,
Ann

Hi Ann,

Thanks for the response. This is related to this thread. I assume this too doesn’t work as I’m not supposed to use the symbolic execution engine for custom rules.

We can close this thread.

Thanks,
Bhathiya

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.