json: cannot unmarshal object when trying to create in toto occurrence
- Dominant language
- Go
- Stars
- 1.6k
- Forks
- 307
- PR merge metrics
- No merged PRs in 30d
Description
## Expected Behavior
Occurrence created as expected
## Actual Behavior
Getting the following error:
```
{
"error": "json: cannot unmarshal object into Go value of type []json.RawMessage",
"message": "json: cannot unmarshal object into Go value of type []json.RawMessage",
"code": 3,
"details": []
}
```
## Steps to Reproduce the Problem
```
POST /v1beta1/projects/provider_example/occurrences HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Content-Length: 1930
{
"resource": {
"name": "docker image",
"uri": "https://gcr.io/scanning-customer/dockerimage@sha256:244fd47e07d1004f0aed9c156aa09083c82bf8944eceb67c946ff7430510a77b",
"contentHash": {
"type": "SHA256",
"value": "244fd47e07d1004f0aed9c156aa09083c82bf8944eceb67c946ff7430510a77b"
}
},
"noteName": "clone",
"kind": "INTOTO",
"intoto": {
"signatures": [
{
"keyid": "<>",
"sig": "<>"
}
],
"signed": {
"command": [
"git",
"clone",
"<>"
],
"materials": [
],
"products": {
"<>": {
"sha256": "<>"
},
"<>": {
"sha256": "<>"
},
"<>": {
"sha256": "<>"
}
},
"byproducts": {
},
"environment": {
}
}
}
}
```
I used the Swagger to find the relevant endpoint, and created it based on existing in toto link.
Prior to this APi call, I successfully created a matching note with the same name and kinda, and created a project.
## Additional info
The server is running using the following docker command:
```
docker run -p 8080:8080 us.gcr.io/grafeas/grafeas-server:v0.1.6
```
Contributor guide
Research direction
Start at the POST /v1beta1/projects/{project}/occurrences endpoint and trace INTOTO occurrence unmarshalling, focusing on the products object in the supplied payload and the []json.RawMessage error. Reproduce the request against the documented v0.1.6 Docker image and verify that the occurrence is created successfully with the same products structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100