diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-01-03 14:46:43 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-01-03 14:46:43 +0100 |
commit | dd4283c38200754a9534c5852ba839c7a0e6b613 (patch) | |
tree | c97972cd7b3b66eeeb99528efbe9d0ea68ed07aa /client | |
parent | d7498cb24e954f830c47d1c7cf5e2471e78af2b2 (diff) |
Check JSON unmarshal error
Diffstat (limited to 'client')
-rw-r--r-- | client/go/vespa/document.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/client/go/vespa/document.go b/client/go/vespa/document.go index e08208eba6d..e8620c59033 100644 --- a/client/go/vespa/document.go +++ b/client/go/vespa/document.go @@ -7,6 +7,7 @@ package vespa import ( "bytes" "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -70,7 +71,9 @@ func sendOperation(documentId string, jsonFile string, service *Service, operati } var doc map[string]interface{} - json.Unmarshal(documentData, &doc) + if err := json.Unmarshal(documentData, &doc); err != nil { + return util.Failure(fmt.Sprintf("Document is not valid JSON: %s", err)) + } operationInFile := operationIn(doc) if operation == anyOperation { // Operation is decided by file content |