dstandish commented on issue #69980:
URL: https://github.com/apache/airflow/issues/69980#issuecomment-4995403320
Here's a mitigation that can be used after the fact:
BEGIN;
CREATE OR REPLACE FUNCTION pg_temp.repair_node(node jsonb) RETURNS jsonb AS
$$
DECLARE k text; v jsonb; out jsonb := '{}'::jsonb;
BEGIN
IF jsonb_typeof(node) = 'object' THEN
IF node ? '__type' AND node ? '__var' THEN
IF node->>'__type' = 'dict' AND jsonb_typeof(node->'__var') = 'object'
THEN
FOR k, v IN SELECT * FROM jsonb_each(node->'__var') LOOP
out := out || jsonb_build_object(k, pg_temp.repair_node(v));
END LOOP;
RETURN jsonb_build_object('__type','dict','__var',out);
END IF;
RETURN node;
ELSE
FOR k, v IN SELECT * FROM jsonb_each(node) LOOP
out := out || jsonb_build_object(k, pg_temp.repair_node(v));
END LOOP;
RETURN jsonb_build_object('__type','dict','__var',out);
END IF;
ELSIF jsonb_typeof(node) = 'array' THEN
RETURN (SELECT jsonb_agg(pg_temp.repair_node(e)) FROM
jsonb_array_elements(node) e);
END IF;
RETURN node;
END;
$$ LANGUAGE plpgsql;
UPDATE callback c
SET data = pg_temp.repair_node(c.data::jsonb)
WHERE jsonb_path_exists(c.data::jsonb, '$.**.__var.* ? (@.type()=="object"
&& !exists(@.__type))');
-- verify: expect 0
SELECT count(*) FROM callback c
WHERE jsonb_path_exists(c.data::jsonb, '$.**.__var.* ? (@.type()=="object"
&& !exists(@.__type))');
COMMIT;
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]