AI Code Fix not generating solution for rule csharpsquid:S2259 in one specific issue

Hello,

We are using SonarCloud (Team plan) and the AI Code Fix feature for C#. We’ve encountered an inconsistency with the rule csharpsquid:S2259 – “Null pointers should not be dereferenced”.

According to the official documentation, this rule is supported by AI Code Fix. However, we’ve found that some issues for this rule successfully generate an AI fix, while others do not, even though they are in the same project and branch.

For example:

  • :white_check_mark: Case where AI Fix works correctly: the button “Generate Fix” returns a valid suggestion.

  • :cross_mark: Case where it fails: the same button displays the message

    “Something went wrong. We are not able to generate a fix for this issue.”

We have verified:

  • The project uses a Quality Gate qualified for AI Code Assurance.

  • The rule S2259 is officially listed as supported.

  • AI Code Fix works fine for other issues in the same project.

Could you please help us understand:

  1. Why some S2259 issues are not eligible for AI Code Fix even though the rule is supported?

  2. Is this expected behavior (for instance, due to contextual complexity or confidence thresholds)?

  3. Is there any additional configuration we should review in our organization settings?

Thank you for your assistance!
We’ll also share this with our SonarCloud contact for further validation.

Best regards,

Hello @ldtorres ,

Thank you for your message. What you have experienced is actually the normal and expected behavior of how AI Code Fix interacts with the LLMs. While it is true that rule S2259 is supported by the feature, sometimes the LLM will respond with content that we are unable to parse.

This can happen for various reasons. For example; sometimes a response contains invalid or empty content, while other times, the LLM simply takes too long to respond. Unfortunately, it is the nature of working with LLMs that sometimes the response just isn’t useful.

I hope this clarifies the behaviour of the feature for you and your colleagues. Please let me know if we can provide any further assistance.

Sincerely,

1 Like