Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

[BUG] incorrect handling of non-JSON media type in Comlink map #358

Open
zdne opened this issue Aug 16, 2023 · 0 comments
Open

[BUG] incorrect handling of non-JSON media type in Comlink map #358

zdne opened this issue Aug 16, 2023 · 0 comments
Labels
AI-related Issue is related to use of AI in our BE

Comments

@zdne
Copy link
Member

zdne commented Aug 16, 2023

Mixpanel' API returns "JSON Lines" in their GET https://data.mixpanel.com/api/2.0/export endpoint.

This is incorrectly handled in map as body.results:

...

const body = response.bodyAuto() ?? {};

if (response.status !== 200) {
  const error = {
    error: body.error || 'An error occurred while fetching data.',
    status: response.status,
    request_id: response.headers['x-request-id']?.[0] || '',
  };
  throw new std.unstable.MapError(error);
}

const results = body.results.map((result) => ({
  event: result.event,
  properties: {
    time: result.properties.time,
    distinct_id: result.properties
...

Note there is no results the body is not JSON at all!

Expected Behavior

Either the CLI (1) fails building the map and reports that it currently does not support JSON lines and user needs to asses it manually. Or (2), preferably, it processes the plain text body, splits the JSON by new lines and parses them before mapping.

Steps to Reproduce

$ sf prepare https://developer.mixpanel.com/reference/query-api "mixpanel"
$ sf new mixpanel "list user activities"
$ sf map ...

Your Environment

  • @superfaceai/cli/4.0.1 darwin-arm64 node-v18.13.0
  • macOS
  • OneSDK 3.0.0-beta.1
  • Node 18.13
@Jakub-Vacek Jakub-Vacek added the AI-related Issue is related to use of AI in our BE label Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AI-related Issue is related to use of AI in our BE
Projects
None yet
Development

No branches or pull requests

2 participants