Was detected as changed but without having changed lines

Hi,
SonarScanner 4.8.0.2856
Our short-lived branch is failing by showing some warnings:

[2023-05-23T05:41:50.251Z] WARN: File '/opt/workDir/*service.spec.ts' was detected as changed but without having changed lines

[2023-05-23T05:41:50.251Z] WARN: File '/opt/workDir/*.spec.ts' was detected as changed but without having changed lines

[2023-05-23T05:41:50.251Z] WARN: File '/opt/workDir/*component.ts' was detected as changed but without having changed lines

[2023-05-23T05:41:57.456Z] INFO: Time spent writing ucfgs 0ms

[2023-05-23T05:41:57.456Z] INFO: ------------------------------------------------------------------------

[2023-05-23T05:41:57.456Z] INFO: EXECUTION FAILURE

[2023-05-23T05:41:57.456Z] INFO: ------------------------------------------------------------------------

[2023-05-23T05:41:57.456Z] INFO: Total time: 4:11.506s

[2023-05-23T05:41:57.456Z] INFO: Final Memory: 55M/220M

[2023-05-23T05:41:57.456Z] INFO: ------------------------------------------------------------------------

[2023-05-23T05:41:57.456Z] ERROR: Error during SonarScanner execution

[2023-05-23T05:41:57.456Z] java.lang.UnsupportedOperationException

[2023-05-23T05:41:57.456Z] 	at java.base/java.util.AbstractCollection.add(AbstractCollection.java:267)

[2023-05-23T05:41:57.456Z] 	at org.sonar.scanner.report.ChangedLinesPublisher.writeChangedLines(ChangedLinesPublisher.java:93)

[2023-05-23T05:41:57.456Z] 	at org.sonar.scanner.report.ChangedLinesPublisher.publish(ChangedLinesPublisher.java:65)

Hey there.

What environment is your analysis running in (locally? A specific CI tool like GitHub Actions, Azure DevOps, Bitbucket Pipelines…)?

Hi @Colin
Jenkins and we run analysis on docker container with sonar-scanner cli installed in it.

Thanks.

Can you describe the git clone behavior being used in your pipeline? Is a full clone (as opposed to a shallow clone) being performed?

Hi @Colin
Its a submodule way
git submodule update --init

Hi @Colin
One more point is, i see dev excluded some files patterns using sonar.exclusions
And in the warning message i can see same pattern of suffix.
Example: *.spec.ts is excluded and some file with the name example.spec.ts is showing as detected as changed but without having changed lines

Lot of confusions @Colin
Scenario:1
If i create branch with the name 1234-builds, getting above warnings and build failing
If i change it to -1234-build build got success.

Scenario:2
If My Branch name contains ‘_’ like ABC_12-Test_Build failing with same issues.
If I remove uderscore from branch names like ABC-12-Test-Build build success.

Can you Please explain me what is this behaviors?

I’ve flagged this behavior for some experts.

Thanks @Colin

Any Update on this issue?

Hi @js-techie ,

We are currently trying to reproduce your issue locally to see if we can find where the error is occurring.

Scenario:1
If i create branch with the name 1234-builds, getting above warnings and build failing
If i change it to -1234-build build got success.

Scenario:2
If My Branch name contains ‘_’ like ABC_12-Test_Build failing with same issues.
If I remove uderscore from branch names like ABC-12-Test-Build build success.

You previously mentioned these two scenarios to us. Could you please confirm how Scenario 1 is working? For example is it ‘- 1234-builds’? Or is it related to the build vs. builds name.

Also could I confirm which languages you are running the test with? I see TS files in your above example, however are you also including others?

It is not related to build vs builds name @shane.findley
Scenario:1
If i create branch with the name 1234-build, getting above warnings and build failing
If i change it to <LonglivedBranchPattern>-1234-build build got success.

Thank you for the information @js-techie, I will see if I can recreate this issue here.

Can I confirm that the long-lived branch pattern you are using is the default one or if you have a custom pattern?

(branch|release)-.*

We defined our own pattern for long lived branches @shane.findley

Hi @js-techie , do you have the details of the exclusion pattern which is being used, I have tried several different configurations on our side and am yet to see any similar failures. I will continue to try iterations to see if I can get a similar failure to occur. Also, do you have the specific command which is being run with the sonar-scanner cli and the associated properties which are being used in the sonar-project.properties file (assuming you are using this).

yeah i will share the details

I am also getting same error in my PR branch …we are doing shallow cloning surprisingly master it is working but in PR it is giving error

[2024-04-29T13:43:31.957Z] [mvn-builder-my-service-parent] [WARNING] 13:43:31.220 Failed to get changed lines from git for file /home/jenkins/workspace/my_service/service/src/test/java/com/test/cancel/CancelResult.java

[2024-04-29T13:43:31.957Z] org.eclipse.jgit.errors.MissingObjectException: Missing blob 3b6eb60e6dcd8958c8d051ad721a639ac320d643

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:137)

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.diff.ContentSource$ObjectReaderSource.open(ContentSource.java:112)

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.diff.ContentSource$Pair.open(ContentSource.java:257)

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.diff.DiffFormatter.open(DiffFormatter.java:1074)

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.diff.DiffFormatter.createFormatResult(DiffFormatter.java:1001)

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:704)

[2024-04-29T13:43:31.957Z] 	at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:691)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scm.git.GitScmProvider.collectChangedLines(GitScmProvider.java:203)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scm.git.GitScmProvider.branchChangedLines(GitScmProvider.java:171)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scanner.report.ChangedLinesPublisher.writeChangedLines(ChangedLinesPublisher.java:92)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scanner.report.ChangedLinesPublisher.publish(ChangedLinesPublisher.java:69)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scanner.report.ReportPublisher.generateReportFile(ReportPublisher.java:163)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:137)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)

[2024-04-29T13:43:31.957Z] 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)

[2024-04-29T13:43:31.957Z] 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)

[2024-04-29T13:43:31.957Z] 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:136)

[2024-04-29T13:43:31.957Z] 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)

[2024-04-29T13:43:31.957Z] 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)

[2024-04-29T13:43:31.957Z] 	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)

[2024-04-29T13:43:31.957Z] 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)

[2024-04-29T13:43:31.957Z] 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)

[2024-04-29T13:43:31.957Z] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[2024-04-29T13:43:31.957Z] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

[2024-04-29T13:43:31.957Z] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[2024-04-29T13:43:31.957Z] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

[2024-04-29T13:43:31.957Z] 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)

[2024-04-29T13:43:31.957Z] 	at jdk.proxy10/jdk.proxy10.$Proxy62.execute(Unknown Source)

[2024-04-29T13:43:31.957Z] 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)

[2024-04-29T13:43:31.957Z] 	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)

[2024-04-29T13:43:31.957Z] 	at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:88)

[2024-04-29T13:43:31.957Z] 	at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:106)

[2024-04-29T13:43:31.957Z] 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)

[2024-04-29T13:43:31.957Z] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)

[2024-04-29T13:43:31.957Z] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)

[2024-04-29T13:43:31.957Z] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)

[2024-04-29T13:43:31.957Z] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)

[2024-04-29T13:43:31.958Z] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)

[2024-04-29T13:43:31.958Z] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)

[2024-04-29T13:43:31.958Z] 	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:210)

[2024-04-29T13:43:31.958Z] 	at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:195)

[2024-04-29T13:43:31.958Z] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

[2024-04-29T13:43:31.958Z] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)

[2024-04-29T13:43:31.958Z] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

[2024-04-29T13:43:31.958Z] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)

[2024-04-29T13:43:31.958Z] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)

[2024-04-29T13:43:31.958Z] 	at java.base/java.lang.Thread.run(Thread.java:833)

[2024-04-29T13:43:31.958Z] 

[2024-04-29T13:43:31.958Z] [mvn-builder-my-service-parent] [WARNING] 13:43:31.221 File '/home/jenkins/workspace/my_service/service/src/test/java/com/test/cancel/CancelResult.java' was detected as changed but without having changed lines

We’re experiencing this on our project now. Did you ever get a response with a resolution?

We experience the similar issue often in case we have edits in pom.xml files.

The diff in PR is available while Sonar analyzing shows these warns

[WARNING] File ‘/pom.xml’ was detected as changed but without having changed lines