java.lang.IllegalStateException: Line 140 is out of range in the file

  • GitHub, CircleCI with the official orb
  • Scanner command: - sonarcloud/scan with no additional arguments
  • Python, JavaScript, HTML
[...]
INFO: Starting global symbols computation
INFO: 33 source files to be analyzed
INFO: 33/33 source files have been analyzed
INFO: Starting rules execution
INFO: 725 source files to be analyzed
INFO: 525/725 files analyzed, current file: packages/app/tests/models/test_object_duplicate_text_index_entry_model.py
INFO: 725/725 source files have been analyzed
INFO: The Python analyzer was able to leverage cached data from previous analyses for 349 out of 725 files. These files were not parsed.
INFO: Sensor Python Sensor [python] (done) | time=14527ms
INFO: Sensor Cobertura Sensor for Python coverage [python]
INFO: Python test coverage
INFO: Parsing report '/home/circleci/project/.tox/coverage/XXX.xml'
INFO: Parsing report '/home/circleci/project/.tox/coverage/XXX2.xml'
INFO: Parsing report '/home/circleci/project/.tox/coverage/XXX3.xml'
INFO: Parsing report '/home/circleci/project/.tox/coverage/XXX4.xml'
INFO: Parsing report '/home/circleci/project/.tox/coverage/XXX5.xml'
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 48.001s
INFO: Final Memory: 74M/215M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Line 140 is out of range in the file .../XXX5/xxx/xxx.py (lines: 138)
	at org.sonar.api.utils.Preconditions.checkState(Preconditions.java:61)
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:67)
	at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(DefaultCoverage.java:55)
	at org.sonar.plugins.python.coverage.CoberturaParser.collectFileData(CoberturaParser.java:156)
	at org.sonar.plugins.python.coverage.CoberturaParser.collectFileMeasures(CoberturaParser.java:109)
	at org.sonar.plugins.python.coverage.CoberturaParser.lambda$parseReport$0(CoberturaParser.java:68)
	at org.sonar.plugins.python.parser.StaxParser.parse(StaxParser.java:62)
	at org.sonar.plugins.python.parser.StaxParser.parse(StaxParser.java:53)
	at org.sonar.plugins.python.coverage.CoberturaParser.parseReport(CoberturaParser.java:72)
	at org.sonar.plugins.python.coverage.PythonCoverageSensor.parseReport(PythonCoverageSensor.java:115)
	at org.sonar.plugins.python.coverage.PythonCoverageSensor.execute(PythonCoverageSensor.java:81)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:464)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Exited with code exit status 1
CircleCI received exit code 1

This is the first PR showing this failure.

Experiment results:

  • Can’t run the scanner with -X because this isn’t supported by the orb
  • Can’t run the scanner manually in the test VM
  • Deleting the coverage files before running the scanner orb avoids the error
  • CircleCI creates a new test VM for each run, no old coverage files exist
  • The PR removes a lot of lines from XXX5/xxx/xxx.py

Solved.

The coverage files are stored in a location that’s cached between runs.

The scanner shouldn’t crash on mismatching coverage files :frowning:

1 Like