Error in SonarLint for IntelliJ 8.3.0.71062

Environment:

  • Java: JetBrains s.r.o. 17.0.6
  • OS: Mac OS X x86_64
  • IDE: PyCharm 2023.1.2
  • SonarLint: 8.3.0.71062
java.lang.StringIndexOutOfBoundsException: begin 4189, end 4194, length 8
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
	at java.base/java.lang.String.substring(String.java:2705)
	at java.base/java.lang.String.subSequence(String.java:2743)
	at c.ij.psi.impl.source.tree.injected.DocumentWindowImpl.prepareReplaceString(DocumentWindowImpl.java:300)
	at c.ij.psi.impl.source.tree.injected.DocumentWindowImpl.replaceString(DocumentWindowImpl.java:349)
	at o.sl.ij.editor.ApplyQuickFixIntentionAction.invoke(ApplyQuickFixIntentionAction.kt:52)
	at c.ij.codeInsight.intention.impl.ShowIntentionActionsHandler.lambda$invokeIntention$8(ShowIntentionActionsHandler.java:273)
	at c.ij.oa.application.WriteAction.lambda$run$1(WriteAction.java:87)
	at c.ij.oa.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:946)
	at c.ij.oa.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:972)
	at c.ij.oa.application.WriteAction.run(WriteAction.java:86)
	at c.ij.codeInsight.intention.impl.ShowIntentionActionsHandler.invokeIntention(ShowIntentionActionsHandler.java:273)
	at c.ij.codeInsight.intention.impl.ShowIntentionActionsHandler.lambda$chooseActionAndInvoke$7(ShowIntentionActionsHandler.java:250)
	at c.ij.oa.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219)
	at c.ij.oa.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
	at c.ij.oa.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164)

Hi @Robert_Malai, thank you for your report!

We had a similar case reported by another user recently, it seems you tried to apply a quick fix. Do you have more information on how this error happened? Are you able to reproduce it?

The one thing that stands out is the fact that I was using some docker containers from my pytest suite.
Nothing else out of the ordinary.

–Robert

Hi @Robert_Malai,

Sorry for the late response. I was not able to reproduce, was it a one-off or do you reproduce the problem consistently?

I saw some possible improvements to make in the code to make it more robust so I created this ticket. I just pushed a fix so it should be available at the next release at the end of the month.

Thanks for reporting here!