IllegalArgumentException while scanning a helm chart after migrating to SonarQube 10.4

Hi,

we get an IllegalArgumentException while scanning a helm chart:

ERROR: Error during SonarScanner execution
java.lang.IllegalArgumentException: 179 is not a valid line for pointer. File cloud-deployment/charts/ngdb-mssql/templates/configmap.yaml has 178 line(s)
	at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
	at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:371)
	at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:307)
	at org.sonar.iac.common.yaml.YamlSensor.toParseException(YamlSensor.java:97)
	at org.sonar.iac.common.extension.IacSensor$Analyzer.lambda$analyseFile$0(IacSensor.java:213)
	at org.sonar.iac.common.extension.DurationStatistics.time(DurationStatistics.java:75)
	at org.sonar.iac.common.extension.IacSensor$Analyzer.analyseFile(IacSensor.java:207)
	at org.sonar.iac.common.extension.IacSensor$Analyzer.analyseFiles(IacSensor.java:184)
	at org.sonar.iac.common.extension.IacSensor.execute(IacSensor.java:111)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
	at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:197)
	at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:193)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:166)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
	at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:138)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
	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(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at jdk.proxy1/jdk.proxy1.$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:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)

In case it is relevant, here are the (censored) logs leading up to the exception above:

log output
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /builds/our/project/sonar-project.properties
INFO: SonarScanner 5.0.1.3006
INFO: Java 17.0.8 Alpine (64-bit)
INFO: Linux 5.15.0-97-generic amd64
INFO: User cache: /opt/sonar-scanner/.sonar/cache
INFO: Analyzing on SonarQube server 10.4.0.87286
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=165ms
INFO: Server id: 86E1FA4D-AW46aIO1ClnTVbBOYaeI
INFO: User cache: /opt/sonar-scanner/.sonar/cache
WARN: sonar.plugins.downloadOnlyRequired is false, so ALL available plugins will be downloaded
INFO: Loading all plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=5792ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Process project properties (done) | time=5ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: our_project
INFO: Base dir: /builds/our/project
INFO: Working dir: /builds/our/project/.scannerwork
INFO: Load project settings for component key: 'our_component'
INFO: Load project settings for component key: 'our_component' (done) | time=23ms
INFO: Load project branches
INFO: Load project branches (done) | time=76ms
INFO: Load branch configuration
INFO: Detected branch/PR in 'GitLab'
INFO: Auto-configuring branch 'XYZ'
INFO: Load branch configuration (done) | time=2ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=45ms
INFO: Auto-configuring with CI 'Gitlab CI'
INFO: Load active rules
INFO: Load active rules (done) | time=2731ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=13ms
INFO: Branch name: XYZ
WARN: The property 'sonar.login' is deprecated and will be removed in the future. Please use the 'sonar.token' property instead when passing a token.
INFO: Preprocessing files...
INFO: 10 languages detected in 1093 preprocessed files
INFO: 4324 files ignored because of inclusion/exclusion patterns
INFO: 16562 files ignored because of scm ignore settings
INFO: Load project repositories
INFO: Load project repositories (done) | time=116ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: [...]
INFO:   Included tests: [...]
INFO:   Excluded tests: [...]
INFO:   Excluded sources for coverage: [...]
INFO: 1093 files indexed
INFO: Quality profile for css: Sonar way
INFO: Quality profile for docker: Sonar way
INFO: Quality profile for java: ourWay
INFO: Quality profile for js: Sonar way Recommended (deprecated)
INFO: Quality profile for json: Sonar way
INFO: Quality profile for scala: ourWay
INFO: Quality profile for ts: ourWay
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Quality profile for yaml: Sonar way
INFO: ------------- Run sensors on module OUR PROJECT
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=17ms
INFO: Sensor JavaSensor [java]
INFO: Configured Java source version (sonar.java.source): 17, preview features enabled (sonar.java.enablePreview): false
INFO: Server-side caching is enabled. The Java analyzer will not try to leverage data from a previous analysis.
INFO: Using ECJ batch to parse 441 Main java source files with batch size 53 KB.
INFO: Starting batch processing.
INFO: The Java analyzer cannot skip unchanged files in this context. A full analysis is performed for all files.
ERROR: Unable to parse source file : 'a/b/src/main/java/com/x/y/z/[...]/TranslationToSerializationMapper.java'
ERROR: Parse error at line 57 column 23: A switch expression should have a default case
ERROR: Unable to parse source file : 'c/d/src/main/java/com/x/y/z/[...]/ViewMapper.java'
ERROR: Parse error at line 74 column 36: A switch expression should have a default case
ERROR: Unable to parse source file : 'e/f/src/main/java/com/x/y/z/[...]/AttachmentConverter.java'
ERROR: Parse error at line 23 column 23: A switch expression should have a default case
ERROR: Unable to parse source file : 'c/d/src/main/java/com/x/y/z/[...]/RuleFromDTOMapper.java'
ERROR: Parse error at line 202 column 39: A switch expression should have a default case
ERROR: Unable to parse source file : 'e/f/src/main/java/com/x/y/z/[...]/ViewToSerializationMapper.java'
ERROR: Parse error at line 52 column 23: A switch expression should have a default case
ERROR: Unable to parse source file : 'g/h/src/main/java/com/x/y/z/[...]/CoreConversions.java'
ERROR: Parse error at line 113 column 27: A switch expression should have a default case
INFO: 100% analyzed
INFO: Batch processing: Done.
INFO: Did not optimize analysis for any files, performed a full analysis for all 441 files.
WARN: Dependencies/libraries were not provided for analysis of SOURCE files. The 'sonar.java.libraries' property is empty. Verify your configuration, as you might end up with less precise results.
WARN: Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
WARN: Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
INFO: No "Test" source files to scan.
INFO: No "Generated" source files to scan.
INFO: Sensor JavaSensor [java] (done) | time=10368ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=59ms
INFO: Sensor IaC Kubernetes Sensor [iac]
INFO: 37 source files to be analyzed
ERROR: Cannot parse 'cloud-deployment/charts/abc-mssql/templates/secrets.yaml'
ERROR: Failed to evaluate Helm file cloud-deployment/charts/censored/templates/deployment.yaml: Template evaluation failed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 25.687s
INFO: Final Memory: 59M/214M
INFO: ------------------------------------------------------------------------

Versions:

  • SonarQube on-Premise 10.4.0
  • Sonar Scanner 5.0.1
  • Java 17.0.8
  • Linux 5.15.0-97-generic amd64

This problem started to occur after upgrading from SonarQube 9.9.1 to 10.4.0, there where no code changes in these files.

Is this a problem on our side or have we found a bug in SonarQube?

Thanks!

Regards,
Carsten

Hey there.

It seems like there’s a bug. Are you able to share cloud-deployment/charts/ngdb-mssql/templates/configmap.yaml so we can understand why parsing failed and threw an exception?

Hi Colin,

thanks for your reply! Can I share it without posting it publicly?

Thanks!

Regards,
Carsten

Hi @Colin ,

one of our developers found out, that adding a new line at the end of the file prevents this problem.
Contrary to the other yaml files, the configmap.yaml does not end with a line break. Especially in combination with multiline strings this seems to be a problem.

Regards,
Carsten

1 Like

Hi @Carsten_HB,

we could reproduce the issue and already fixed it. It will be shipped with the next release.

Best,

2 Likes

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