Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/zenoss/jsonapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def parse_json(resp)
end

json = JSON.load(resp.http_body.content)
# Handle the situation where the 'result' key in the JSON response does not
# point to a hash, but instead is nil.
# This has been seen in the wild on an installation of Zenoss 4.2.5
if json['result'].nil?
raise ZenossError, "JSON request '#{json['method']}' on '#{json['action']}' returned malformed data"
end

# Check for JSON success. There are some exceptions where this doesn't make sense:
# 1. Sometimes the 'success' key does not exist like in EventsRouter#query
# 2. When json['result'] is not a Hash like a return from ReportRouter#get_tree
Expand Down