[BUG] Bounds check (Intellij plugin)

Resolved 💬 1 comment Opened Apr 15, 2026 by otembajelle Closed May 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Version: 2.1.109 (Claude Code)
Source: Claude itself ...
Proper fix (for Anthropic to address)

The plugin needs a bounds check in DiagnosticTools.kt before calling getLineNumber:
val docLen = document.textLength
if (highlight.startOffset in 0 until docLen) {
val line = document.getLineNumber(highlight.startOffset)
// ...
}

What Should Happen?

No exception when it runs

Error Messages/Logs

Your plugin for Intellij throws an exception. How can we fix that? java.lang.IndexOutOfBoundsException: Wrong offset: 3313104. Should be in range: [0, 392356]                                                                                                                                         
      at com.intellij.openapi.editor.impl.LineSet.findLineIndex(LineSet.java:167)                                                                                                                                                                                                                        
      at com.intellij.openapi.editor.impl.DocumentImpl.getLineNumber(DocumentImpl.java:1050)                                                                                                                                                                                                             
      at com.anthropic.code.plugin.mcp.tools.DiagnosticTools$addTools$1$1$1.daemonFinished$lambda$0(DiagnosticTools.kt:124)                                                                                                                                                                              
      at com.anthropic.code.plugin.mcp.tools.DiagnosticTools$addTools$1$1$1.daemonFinished$lambda$1(DiagnosticTools.kt:118)                                                                                                                                                                              
      at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx.lambda$processHighlights$0(DaemonCodeAnalyzerEx.java:83)                                                                                                                                                                              
      at com.intellij.openapi.editor.impl.MarkupModelImpl.processRangeHighlightersOverlappingWith(MarkupModelImpl.java:285)                                                                                                                                                                              
      at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx.processHighlights(DaemonCodeAnalyzerEx.java:76)                                                                                                                                                                                       
      at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx.processHighlights(DaemonCodeAnalyzerEx.java:62)                                                                                                                                                                                       
      at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx.processHighlights(DaemonCodeAnalyzerEx.java:49)                                                                                                                                                                                       
      at com.anthropic.code.plugin.mcp.tools.DiagnosticTools$addTools$1$1$1.daemonFinished(DiagnosticTools.kt:112)                                                                                                                                                                                       
      at com.intellij.codeInsight.daemon.DaemonCodeAnalyzer$DaemonListener.daemonFinished(DaemonCodeAnalyzer.java:98)                                                                                                                                                                                    
      at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:818)                                                                                                                                                                                                            
      at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:762)                                                                                                                                                                                                          
      at com.intellij.util.messages.impl.MessageBusImplKt.executeOrAddToQueue(MessageBusImpl.kt:583)                                                                                                                                                                                                     
      at com.intellij.util.messages.impl.MessagePublisher.publish$intellij_platform_core(MessageBusImpl.kt:554)                                                                                                                                                                                          
      at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:531)                                                                                                                                                                                                                  
      at jdk.proxy2/jdk.proxy2.$Proxy91.daemonFinished(Unknown Source)                                                                                                                                                                                                                                   
      at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl$MyDaemonProgressIndicator.onStop(DaemonCodeAnalyzerImpl.java:1649)                                                                                                                                                                  
      at com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator.stop(DaemonProgressIndicator.java:39)                                                                                                                                                                                              
      at com.intellij.codeInsight.daemon.impl.PassExecutorService.lambda$applyInformationToEditorsLater$3(PassExecutorService.java:554)                                                                                                                                                                  
      at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:240)                                                                                                                                                                                      
      at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:26)                                                                                                                                                                                                  
      at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:202)                                                                                                                                                                                                      
      at com.intellij.openapi.application.impl.AppImplKt$runnableUnitFunction$1.invoke(appImpl.kt:104)                                                                                                                                                                                                   
      at com.intellij.openapi.application.impl.AppImplKt$runnableUnitFunction$1.invoke(appImpl.kt:104)                                                                                                                                                                                                   
      at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.doRunWriteIntentReadAction(NestedLocksThreadingSupport.kt:666)                                                                                                                                                                   
      at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.runPreventiveWriteIntentReadAction(NestedLocksThreadingSupport.kt:640)                                                                                                                                                           
      at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.runWriteIntentReadAction(NestedLocksThreadingSupport.kt:633)                                                                                                                                                                     
      at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:1022)                                                                                                                                                                          
      at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:574)                                                                                                                                                                                                           
      at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:167)                                                                                                                                                                                                       
      at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:167)                                                                                                                                                                                                       
      at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:173)                                                                                                                                                                                                                
      at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:167)                                                                                                                                                                                                                
      at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)                                                                                                                                                                                                                      
      at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:122)                                                                                                                                                                                                              
      at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:43)                                                                                                                                                                                                                   
      at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)                                                                                                                                                                                                                  
      at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)                                                                                                                                                                                                                         
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)                                                                                                                                                                                                                                     
      at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)                                                                                                                                                                                                                                     
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)                                                                                                                                                                                                                
      at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)                                                                                                                                                                               
      at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)                                                                                                                                                                                                                             
      at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:595)                                                                                                                                                                                                                       
      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:488)                                                                                                                                                                                                                             
      at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12$lambda$11$lambda$10$lambda$9(IdeEventQueue.kt:313)                                                                                                                                                                                       
      at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:865)                                                                                                                                                                                         
      at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12$lambda$11$lambda$10(IdeEventQueue.kt:312)                                                                                                                                                                                                
      at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$3(IdeEventQueue.kt:974)                                                                                                                                                                                                                 
      at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:110)                                                                                                                                                                                            
      at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:974)                                                                                                                                                                                                                          
      at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12(IdeEventQueue.kt:307)                                                                                                                                                                                                                    
      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:347)                                                                                                                                                                                                                              
      at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)                                                                                                                                                                                                  
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)                                                                                                                                                                                                     
      at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)                                                                                                                                                                                                  
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)                                                                                                                                                                                                              
      at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)                                                                                                                                                                                                              
      at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Steps to Reproduce

The exception is in DiagnosticTools.kt:124. The daemon finishes analyzing the file, then calls document.getLineNumber(3313104) — but the document only has 392,356 bytes at that point. The offset is ~8× larger than the current document size.

The cause: you opened unified_runner_output.log in the IDE. The backend is actively writing to it. The sequence is:

  1. IntelliJ daemon runs on the file when it is ~3.3 MB
  2. The log file keeps growing (or IntelliJ reloads it mid-flight, or truncation happened)
  3. By the time the daemon calls getLineNumber(highlight.startOffset) the document has been replaced with a smaller version (392 KB)
  4. The stale offset is now out of range → IndexOutOfBoundsException

This is a real bug in the plugin (no bounds check before getLineNumber), but you can work around it immediately:

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.109

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

IntelliJ IDEA terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗