Skip to content
Snippets Groups Projects
Commit 2855e353 authored by Michal Zander's avatar Michal Zander Committed by Bartek Wrona
Browse files

Catch null results in json-rpc apis

parent 8442a808
No related branches found
No related tags found
1 merge request!148Catch null results in json-rpc apis
Pipeline #107663 passed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment