Error : Unable to parse file

Hi Team,

We are using the SonarQube version 8.9.10.61524.

We have a project written in Go lang(go1.19.2) and sonar scanning is failing with the following error:

ERROR: Unable to parse file: file:///builds/example///.go.
382ERROR: Cannot parse ‘com/example//’: Go parser external process returned non-zero exit value: 2

Can you please guide us to fix this issue.

Thanks!

Hey there.

Without the file in question, it won’t be obvious what’s causing the issue. And, SonarQube v8.9 LTS only supports up Go v1.15, which was the version released at the time. SonarQube v9.7 should support up to Go v1.19.

Hi Colin,

Here is the log of the issue and the file

ERROR: Unable to parse file: file:///builds/pearsontechnology/gpt/cls/dos/dos-mds-data-retriever-lambda/com/pearson/dos/lambda/util/Unmarshaller.go.
382ERROR: Cannot parse ‘com/pearson/dos/lambda/util/Unmarshaller.go’: Go parser external process returned non-zero exit value: 2
383ERROR: Unable to parse file: file:///builds/pearsontechnology/gpt/cls/dos/dos-mds-data-retriever-lambda/com/pearson/dos/lambda/service/PiTokenService.go.
384ERROR: Cannot parse ‘com/pearson/dos/lambda/service/PiTokenService.go’: Go parser external process returned non-zero exit value: 2
385ERROR: Unable to parse file: file:///builds/pearsontechnology/gpt/cls/dos/dos-mds-data-retriever-lambda/com/pearson/dos/lambda/repo/MdsRepository.go.
386ERROR: Cannot parse ‘com/pearson/dos/lambda/repo/MdsRepository.go’: Go parser external process returned non-zero exit value: 2
387ERROR: Unable to parse file: file:///builds/pearsontechnology/gpt/cls/dos/dos-mds-data-retriever-lambda/com/pearson/dos/lambda/repo/PiTokenRepository.go.
388ERROR: Cannot parse ‘com/pearson/dos/lambda/repo/PiTokenRepository.go’: Go parser external process returned non-zero exit value: 2
389ERROR: Unable to parse file: file:///builds/pearsontechnology/gpt/cls/dos/dos-mds-data-retriever-lambda/com/pearson/dos/lambda/core/Runner.go.
390ERROR: Cannot parse ‘com/pearson/dos/lambda/core/Runner.go’: Go parser external process returned non-zero exit value: 2

Regards,

Hello Colin - We have shared the logs of the error. Please find the one shared by Rupitha. Can you please check and provide an update?

Thank you for your help!

Hey there!

First, please don’t bump threads.

Second, to determine if the parsing error is the result of newer syntax that SonarQube v8.9 LTS doesn’t support… you would have to share the file (as noted in my last response). And, it’s really likely that you face what I mentioned before.

Given that this is a Go 1.19 project.

Hi Colin,

Apologies, I did not mean to bump the threads. I am actively following up on this issue reported by Rupitha and the most recent update from our user, Imteyaz Ahmad, is:

We are using generics from Go lang(introduced in go1.18–Go 1.18 Release Notes - The Go Programming Language). below is the example for the same. Our parser fails wherever we have used the generics:

package util

import (
“encoding/json”
)

type DosUnmarshalerInterface[T any] interface {
Unmarshal(bytes []byte, v T) (T, error)
}

type DosUnmarshaler[T any] struct {
}

*func (mds DosUnmarshaler[T]) Unmarshal(bytes []byte, v T) (T, error) {
err := json.Unmarshal(bytes, &v)
var result T
if err != nil {
return result, err
}
return v, nil
}

This is the code he got in the GO file which, for some reason, is not getting uploaded here. Can you please advise?

Thank you!

Hello Colin - Can you please advise if you have an update on this?

Thanks!

Hey there.

If the code uses generics, introduced in Go 1.18 – then I think everything I’ve posted already sums it up! Go 1.18 syntax isn’t supported in SonarQube v8.9 LTS, it is supported in the latest v9.x versions (and will be supported in v9.x LTS, targeted for Q1 2023.