Why Am I Seeing a 'TransformRequest Could Not Be Cloned' Error?

This topic was automatically generated from Slack. You can find the original thread here.

why would I be seeing an error of transformRequest could not be cloned?

The error message “transformRequest could not be cloned” suggests that there’s an issue with how a request is being transformed before it’s sent in a workflow or component. This could be related to a custom transformation function that’s not serializable or has elements that cannot be cloned as part of the request preparation process. Without specific details about the context in which you’re encountering this error, it’s challenging to provide a precise solution. However, here are a few general steps you can take to troubleshoot and potentially resolve this issue: 1. Review Custom Transformation Functions: If you’re using a custom transformRequest function in an Axios request or similar, ensure that all operations within the function are serializable. This means avoiding the use of functions, class instances, or other non-serializable values in the request configuration. 2. Simplify the Request Configuration: Temporarily simplify your request configuration to the most basic form without any transformations. If the error goes away, gradually reintroduce elements of your original configuration to identify the problematic part. 3. Check for Unsupported Data Types: Ensure that you’re not attempting to send unsupported data types (like File, Blob, or custom class instances) without properly serializing them first. 4. Consult Documentation and Community: Review any relevant documentation or community forums for the library or API you’re working with. There might be known issues or limitations with certain types of request transformations. If you’re still encountering issues after trying these steps, could you provide more details about the specific workflow, component, or request configuration where you’re seeing this error? This information would help in giving a more targeted solution.

Yea sure. I’m not using any transformations but I am uploading a file:

    let attachment_rows = steps.get_from_db.$return_value.attachments.rows;
    let attachment_promises = [];
    for(let a in attachment_rows) {
      let row = attachment_rows[a];

      // Load the file into temp
      await pipeline(
        got.stream(row.url),
        fs.createWriteStream(`/tmp/${row.attachment_id}`)
      );

      // Build the form including reading the temp file
      const formData = new FormData();
      formData.append("query", `mutation add_file($file: File!) {add_file_to_column (item_id: ${obscuring_item_id}, column_id:"files" file: $file) {id}}`);
      formData.append("map", `{"upload":"variables.file"}`);
      await formData.append("upload", fs.createReadStream(`/tmp/${row.attachment_id}`));

      // Submit it to Monday.com
      attachment_promises.push(http({
        method: 'post',
        url: `https://api.monday.com/v2/file`,
        headers: {
          "API-version": "2023-10",
          "Accept": "**/**",
          "Authorization": `${this.monday.$auth.api_key}`,
          "Content-Type": `multipart/form-data; boundary=${formData.getBoundary()}`
        },
        data: formData
      }));
    }

any thoughts on the code above?

It appears there was no specific code or context provided in your question. Could you please share more details or clarify the code snippet or issue you’re referring to? This will help me provide a more accurate and helpful response.

this is the code snippet that is causing the transformRequest could not be cloned error. I believe it has something to do with the use of FormData but don’t understand the error to resolve it.

    let attachment_rows = steps.get_from_db.$return_value.attachments.rows;
    let attachment_promises = [];
    for(let a in attachment_rows) {
      let row = attachment_rows[a];

      // Load the file into temp
      await pipeline(
        got.stream(row.url),
        fs.createWriteStream(`/tmp/${row.attachment_id}`)
      );

      // Build the form including reading the temp file
      const formData = new FormData();
      formData.append("query", `mutation add_file($file: File!) {add_file_to_column (item_id: ${obscuring_item_id}, column_id:"files" file: $file) {id}}`);
      formData.append("map", `{"upload":"variables.file"}`);
      await formData.append("upload", fs.createReadStream(`/tmp/${row.attachment_id}`));

      // Submit it to [Monday.com](http://Monday.com)
      attachment_promises.push(http({
        method: 'post',
        url: `https://api.monday.com/v2/file`,
        headers: {
          "API-version": "2023-10",
          "Accept": "**/**",
          "Authorization": `${this.monday.$auth.api_key}`,
          "Content-Type": `multipart/form-data; boundary=${formData.getBoundary()}`
        },
        data: formData
      }));
    }

It looks like you’re encountering an issue with making a multipart/form-data request to the monday.com API using FormData in a Pipedream workflow. The error transformRequest could not be cloned suggests there’s an issue with how the request is being serialized or sent. In Pipedream workflows, when making HTTP requests with FormData, especially for file uploads, it’s important to ensure the request is correctly formatted and that the axios library from @pipedream/platform is used. This library is optimized for use within Pipedream and handles the serialization of FormData correctly. Here’s a revised version of your code snippet that should work within a Pipedream workflow. This example assumes you’re trying to upload a file to a monday.com item: ``` import { axios } from “@pipedream/platform”; import fs from “fs”; import FormData from “form-data”; import stream from “stream”; import { promisify } from “util”; import got from “got”; export default defineComponent({ props: { monday: { type: “app”, app: “monday”, }, }, async run({ steps, $ }) { let attachment_rows = steps.get_from_db.$return_value.attachments.rows; let attachment_promises = attachment_rows.map(async (row) => { // Load the file into temp const pipeline = promisify(stream.pipeline); await pipeline( got.stream(row.url), fs.createWriteStream(/tmp/${row.attachment_id}) ); // Build the form including reading the temp file const formData = new FormData(); formData.append(“query”, mutation add_file($file: File!) {add_file_to_column (item_id: ${obscuring_item_id}, column_id:"files" file: $file) {id}}); formData.append(“map”, {"upload":"variables.file"}); formData.append(“upload”, fs.createReadStream(/tmp/${row.attachment_id})); // Submit it to monday.com return axios($, { method: ‘post’, url: https://api.monday.com/v2/file, headers: { “Authorization”: ${this.monday.$auth.api_key}, …formData.getHeaders(), }, data: formData, }); }); // Wait for all file uploads to complete return await Promise.all(attachment_prom

okay that helps, I was using the axios-rate-limiter though to slow my requests. How can I do that with the axios provided by pipedream?