GetProject method sometime fails due to wrong type return by the depsdev API
zaibon opened this issue · 3 comments
Describe the bug
Some project detail in the depsdev database have the wrong type in the ossFuzz object.
Example: https://api.deps.dev/v3alpha/projects/github.com%2Fklauspost%2Fcompress
lineCount
and lineCoverCount
are strings while they should be integer. This prevents the unmarshaling of this project by this library.
To Reproduce
Steps to reproduce the behavior:
- use the
GetProject
with argument"github.com/klauspost/compress"
Expected behavior
Get project details from the API
Hi @zaibon, what do you mean with This prevents the unmarshaling of this project by this library
?
The command
depsdev project "github.com/klauspost/compress" | jq
works fine for me.
lineCount
and lineCoverCount
are int64
in the ossFuzz struct.
Try this code:
package main
import (
"fmt"
"github.com/edoardottt/depsdev/pkg/depsdev"
)
func main() {
client := depsdev.NewAPI()
i, err := client.GetProject("github.com/klauspost/compress")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(i)
}
Running this code returns: json: cannot unmarshal string into Go struct field OssFuzz.ossFuzz.lineCount of type int64
lineCount and lineCoverCount are int64 in the ossFuzz struct.
Which is correct type according to the documentation of the depsdev API. But it seems, for some project, depsdev API returns a string for those field. That is clearly a bug on the depsdev side. But maybe we could mitigate it in the API by manually checking the type of those field and unmarshaling properly depending if its a integer or a string.
Thanks for let me know ! @zaibon
Actually I'm not the maintainer of the deps.dev APIs since that it's a Google project (https://github.com/google/deps.dev). I'll open an issue and see what they reply to me.