Skip to content

net_http_request table from net plugin fails to handle jsonb_build_object in WHERE clauses #255

@hellupline

Description

@hellupline

when I use a jsonb_object with both keys and values as literal arrays, the request runs as expected,
but when I use an ARRAY [...] or jsonb_build_object the result is a empty set,
when the request hit the target server, the request is also missing headers,
and if using jsonb_build_object on body, body also goes empty

this snipplet contains 3 example cases

-- success
SELECT *
FROM net_http_request
WHERE
    url = 'https://webhook.site/6cf89317-df09-40bb-b14a-30b4e83412a9?case=1'
    AND method = 'POST'
    AND request_headers = jsonb_object(
        '{accept, content-type, authorization}',
        '{application/json, application/json, Bearer testing}'
    )
    AND request_body = jsonb_object(
        '{key}',
        ARRAY ['value']
    )::TEXT;
​
​
--- no headers sent
SELECT *
FROM net_http_request
WHERE
    url = 'https://webhook.site/6cf89317-df09-40bb-b14a-30b4e83412a9?case=2'
    AND method = 'POST'
    AND request_headers = jsonb_object(
        '{accept, content-type, authorization}',
        ARRAY ['application/json', 'application/json', FORMAT('Bearer %s', 'testing')]
    )
    AND request_body = jsonb_object(
        '{key}',
        ARRAY ['value']
    )::TEXT;
​
​
-- no header, no body sent
SELECT *
FROM net_http_request
WHERE
    url = 'https://webhook.site/6cf89317-df09-40bb-b14a-30b4e83412a9?case=3'
    AND method = 'POST'
    AND request_headers = jsonb_build_object(
        'accept', 'application/json',
        'content-type', 'application/json',
        'authorization', 'Bearer testing'
    )
    AND request_body = jsonb_build_object(
        'key', ARRAY ['value']
    )::TEXT;
​
​
​-- all 3 json objects on `TEXT` serialization are equal
SELECT
    jsonb_object(
        '{accept, content-type, authorization}',
        ARRAY ['application/json', 'application/json', FORMAT('Bearer %s', 'testing')]
    )::TEXT =
    jsonb_object(
        '{accept, content-type, authorization}',
        '{application/json, application/json, Bearer testing}'
    )::TEXT,
    jsonb_object(
        '{accept, content-type, authorization}',
        ARRAY ['application/json', 'application/json', FORMAT('Bearer %s', 'testing')]
    )::TEXT =
    jsonb_build_object(
        'accept', 'application/json',
        'content-type', 'application/json',
        'authorization', 'Bearer testing'
    )::TEXT;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions