Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: HTTP Post piece errors out when it should not #4295

Closed
Gaket opened this issue Mar 27, 2024 · 4 comments
Closed

[BUG]: HTTP Post piece errors out when it should not #4295

Gaket opened this issue Mar 27, 2024 · 4 comments

Comments

@Gaket
Copy link

Gaket commented Mar 27, 2024

Describe the bug
HTTP Post piece seems not to work as expected in some cases.

When a specific POST request is sent with this body via Active Pieces, it returns an error:

image
{
  "type": "TYPE_INDIVIDUAL",
  "fields": [
    "Uid",
    "Email",
    "user_shop_str",
    "user_userType_str",
    "user_shopId_str"
  ],
  "format": "FORMAT_CSV",
  "segmentId": "{{step_2['segmentId']}}",
  "timeRange": "{{step_2['timeRange']}}"
}

I created a code piece that seemingly does the same thing, but it works as expected:

export const code = async (inputs) => {
const response = await fetch('https://api.fullstory.com/segments/v1/exports', {
    method: 'POST',
    headers: {
      'User-agent': 'fs-postman/1.0',
      'Authorization': 'Basic na1.MTc4WEZRL2FydH--redacted',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      type: 'TYPE_INDIVIDUAL',
      format: 'FORMAT_CSV',
      segmentId: inputs.segmentId,
      timeRange: inputs.timeRange
    })
  });

  if (!response.ok) {
    throw new Error(`Error: ${response.statusText}`);
  }

  return await response.json();
};

The unexpected server response is:

{
  "response": {
    "status": 400,
    "body": {
      "error": "fs/services/dex/internal/searchexport/searchexport.go:580 [(*Service).buildExportFromRequest] invalid search export type: TYPE_INVALID"
    }
  },
  "request": {}
}

the step input is shown as:

{
  "url": "https://api.fullstory.com/segments/v1/exports",
  "body": "{\"type\":\"TYPE_INDIVIDUAL\",\"fields\":[\"Uid\",\"Email\",\"user_shop_str\",\"user_userType_str\",\"user_shopId_str\"],\"format\":\"FORMAT_CSV\",\"segmentId\":\"IfoSM8oaHf63\",\"timeRange\":\"{\"start\":\"2024-03-26T15:02:22.671Z\",\"end\":\"2024-03-27T15:02:22.671Z\"}\"}",
  "method": "POST",
  "headers": {
    "User-Agent": "fs-postman/2.0",
    "Content-Type": "application/json",
    "Authorization": "Basic na1.MTc4WEZRL2FydHVyQGdldHNxdWlyZS5jb206u8+by7/jPBiPrpdyKTOTUuv+tKQzeQjf4ZeKmFCfcOgu/FG8X8SK"
  },
  "failsafe": false,
  "queryParams": {}
}

Is it expected that it has all these backslashes?

To Reproduce
Unfortunately, that's a 3-rd party service requiring auth. Let me know how can I share a token to be able to actually call the code if it helps.

Expected behavior
Getting the expected answer, eg:

{
  "status": 200,
  "headers": {
    "content-length": "94",
    "content-type": "application/json",
    "date": "Tue, 26 Mar 2024 15:00:57 GMT",
    "x-grpc-status": "0",
    "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000, h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
    "via": "1.1 google, 1.1 google",
    "x-fullstory-data-realm": "na1",
    "connection": "close"
  },
  "body": {
    "operationId": "U0VBUkNIX0VYUE9SVDppUU5XMGN3RjU2QzlvaF9vTG93WFB2Y1JBNU9sN19CWGdWNk9ENmNHVXhB"
  }
}

Screenshots
image

Additional context
I believe the piece used to work in previous tens of runs and only recently started to behave like this. May it be a regression? It worked on March 26 and failed on March 27.

@kishanprmr
Copy link
Collaborator

Hello @Gaket,

Could you please try recreating the HTTP step, considering you are using version v0.3.10 for a piece where the latest version is v0.4.3?

@abuaboud
Copy link
Contributor

Hi @Gaket

I think I saw another issue might related to it, which is now fixed.

Please reopen if you still can reproduce on latest version.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If this issue is continuing with the latest stable version of Activepieces, please open a new issue that references this one.

@Gaket
Copy link
Author

Gaket commented Apr 30, 2024

Thank you! The latest piece, 0.4.4 worked as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants