File path exceeds 400 character limit error

  • which versions are you using SonarQube 9.9.0.65466
  • how is SonarQube deployed: zip
  • what are you trying to achieve: scanning files which are longer than 400 caracters
  • what have you tried so far to achieve this: run a pipeline

On the bug report page [SONAR-14584] - Jira it says that this bug is fixed but i am still facing this issue with the 9.9 version.
Is this fix rolled out in the 9.9 version or will it be rolled out in 9.10?

Hi,

Could you share the analysis log, please? Or at least the full error message and stacktrace?

 
Ann

The Error is:


##[error]ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Component key (long-directory-names:very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/very-very-long-path-to-file/test.py) length (588) is longer than the maximum authorized (400)
	at org.sonar.api.batch.fs.internal.DefaultIndexedFile.validateKeyLength(DefaultIndexedFile.java:84)
	at org.sonar.api.batch.fs.internal.DefaultIndexedFile.<init>(DefaultIndexedFile.java:78)
	at org.sonar.scanner.scan.filesystem.FileIndexer.indexFile(FileIndexer.java:145)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer$IndexFileVisitor.visitFile(ProjectFileIndexer.java:274)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer$IndexFileVisitor.visitFile(ProjectFileIndexer.java:246)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2725)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexDirectory(ProjectFileIndexer.java:221)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexFiles(ProjectFileIndexer.java:207)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(ProjectFileIndexer.java:169)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexModulesRecursively(ProjectFileIndexer.java:148)
	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(ProjectFileIndexer.java:115)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:363)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	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:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	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:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)

It can Be reproduced if you run the following and then start the scanner:

for ((i = 1; i <= 20; i++)); do
  mkdir very-very-long-path-to-file
  cd very-very-long-path-to-file
done
touch test.py
echo "print('test')" >test.py

This is just an example code snipped, we have the real issue when files/folders are autogenerated.

1 Like

Hi,

Thanks for this. I’m going to flag it for the team, although I’m not sure there’s much to be done.

 
Ann

Hi @di.baumann,

Many thanks for your question. I understand what you are trying to do. However, this limitation is enforced by SonarQube at the scanner level to prevent the compute engine from failing. The ticket outcome was to implement this limitation. In short, there is currently no way of analyzing files that have paths of over 400 characters.

Regards
Alain