Skip to content

Commit

Permalink
fix(generate): handle missing result in API responses
Browse files Browse the repository at this point in the history
If an endpoint returns an incorrect envelope, just skip over it since it isn't usable anyway
  • Loading branch information
jacobbednarz committed Jan 23, 2025
1 parent 4a583c7 commit af03ef9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/app/cf-terraforming/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func generateResources() func(cmd *cobra.Command, args []string) {
}

value := gjson.Get(string(body), "result")
if value.Type == gjson.Null {
log.Debugf("no result found at %s. skipping...", endpoint)
continue
}
err = json.Unmarshal([]byte(value.String()), &jsonStructData)
if err != nil {
log.Fatalf("failed to unmarshal result: %s", err)
Expand Down

0 comments on commit af03ef9

Please sign in to comment.