Skip to content
Snippets Groups Projects

Catch null results in json-rpc apis

Closed Michal Zander requested to merge mzander/workaround-for-null into develop
1 file
+ 7
2
Compare changes
  • Side-by-side
  • Inline
@@ -42,7 +42,7 @@ DECLARE
__params JSON;
__id JSON;
__result JSON;
__result JSONB;
__api_type TEXT;
__method_type TEXT;
__is_legacy_style BOOLEAN;
@@ -53,7 +53,7 @@ BEGIN
__params = (__request_data->'params');
__id = (__request_data->'id');
SELECT NULL::JSON INTO __result;
SELECT NULL::JSONB INTO __result;
IF __jsonrpc != '2.0' OR __jsonrpc IS NULL OR __params IS NULL OR __id IS NULL THEN
RETURN hafah_backend.raise_exception(-32600, 'Invalid JSON-RPC');
@@ -90,6 +90,11 @@ BEGIN
END IF;
END IF;
IF __result = 'null' THEN
RAISE NOTICE 'null in % api', __method;
__result := '[]'::JSONB;
END IF;
IF __result IS NULL THEN
RETURN hafah_backend.raise_exception(-32601, 'Method not found', __method, __id);
ELSEIF __result->'error' IS NULL THEN
Loading