Skip to content

HTTP PATCH - Weird Errors and Queries #31

@drveresh

Description

@drveresh

I have an EdgeFunction (EF) code that executes based on the request.method === "PATCH", and I am triggering the same PATCH type request via POSTMAN, but getting below weird console logs:

error 2024-08-20 17:26:23 (UTC+05:30) | 1:1 no such column: status
error 2024-08-20 17:26:23 (UTC+05:30) functions_replaceFunction - http://***:8090/v2/functions/myFunction?id=2798942&status=m
error 2024-08-20 17:26:23 (UTC+05:30) UPDATE functions SET 'id' = 'fn_liBvg3orbzDs', 'status' = 'm', 'options' = NULL WHERE id IS 'fn_liBvg3orbzDs' OR slug IS 'myFunction';

The POSTMAN endpoint looks like below, both with and without query params:

http://***:8090/v2/functions/myFunction?id=2798942&status=m
http://***:8090/v2/functions/myFunction <<with request body "{"id": 2798942,"status": "m"}">>

Below is the EF Code:

//let id = request.data?.id, status = request.data?.status; //When payload is part of request body
let id = request.params.id, status = request.params.status; //Via URL params set
let query = `UPDATE BadDomains set status='${status}' WHERE id=${id}`;
result = await connection.sql(query);
message = `Number of updates: ${result.length}`;

What is really going on here?

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