How to debug Workflow Automation

Hi folks,
I have interesting issue.

When I run automation from editor, everything looks ok and file is uploaded to S3 (AWS s3, using upload promise).

When I run same script using action (custom button), workflow state is green, log seems ok, but the file is not uploaded.

Can someone tell me where could be the problem?

Thank you
Petr

    async function getPromise(url: string, access_token: string, config:object){
        console.log("Get upload promise")
        var myHeaders = new Headers();
        myHeaders.append("Accept", "application/json");
        myHeaders.append("Content-Type", "application/json");

        var body = {
            instance: config.instance,
            instance_key: config.instance_key
        }

        var requestOptions = {
            method: "POST",
            bearer: access_token,
            headers: myHeaders,
            body: JSON.stringify(body)
        };

        var resp = await doo.functions.request.custom(url, requestOptions);
        console.log(resp);

        return resp
    }
    
    async function s3upload(url: string, access_token: string, config: object, file: File){
        console.log("Upload file to S3")
        const promise = await getPromise(url, access_token, config)

        console.log("Promise has been granted")
        const s3url = promise.url
        const myHeaders = new Headers();

        myHeaders.append("Accept", "application/json");

        var data = new FormData()
        data.append("key", promise.fields.key)
        data.append("x-amz-algorithm", promise.fields["x-amz-algorithm"])
        data.append("x-amz-credential", promise.fields["x-amz-credential"])
        data.append("x-amz-date", promise.fields["x-amz-date"])
        data.append("x-amz-security-token", promise.fields["x-amz-security-token"])
        data.append("policy", promise.fields.policy)
        data.append("x-amz-signature", promise.fields["x-amz-signature"])
        data.append("file", file)

        for (var pair of data.entries()) {
            console.log(pair[0]+ ': ' + pair[1]);
        }

        var requestOptions = {
            method: "POST",
            headers: myHeaders,
            mode: "no-cors",
            body: data
        };

        var resp = await fetch(s3url, requestOptions)
                            .then(data => {
                                console.log(data);
                            })
                            .catch(e => {
                                console.log(e);

                            });

        console.log(resp)                            
    }

Hi,

Do you have WF Run on server checked? Or WF is running on the client, then you might be able to find a possible bug in the development environment (F12).

Regards,

Filip

Hi Filip,
yes, wf is running on server under api token. During debugging I got error from AWS

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>PreconditionFailed</Code>
  <Message>At least one of the pre-conditions you specified did not hold</Message>
  <Condition>Bucket POST must be of the enclosure-type multipart/form-data</Condition>
  <RequestId>CPHFDP20PN5QJM96</RequestId>
  <HostId>***</HostId>
</Error>

From this message is obvious, that tabidoo do not send ContentType properly. It seams there is a bug in fetch implementation on server side.

There can be the difference. When I run JS on client side, fetch is ok, on server side fetch is corrupted.

Do you have any ideas how to solve this?

Regards
Petr

Hi,

we will test your script to find any errors.

With Regards, FIlip.

Hi,
thank you, give me a notice if I can help, or explain AWS side.
Petr