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 Report: Getting 500 error when accessing prop on third-party response object. #6999

Closed
2 tasks done
logan-waite opened this issue Oct 24, 2023 · 10 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions. question Further information is requested stale

Comments

@logan-waite
Copy link

👟 Reproduction steps

In an Appwrite function, I'm trying to access data from a third-party SDK, which works in other instances. However, when I try to access the data in this call, I'm getting a 500 error An internal curl error has occurred within the executor! Error Msg: Http invalid protocol\nError Code: 500. The error might make sense if it happened when I await the plaid.transactionsSync (which is the actual http call), but I know I'm getting valid data from that through logging. However, as soon as I try to access the data prop on that response (which I know exists), I get that 500 error.

  const databases = new Databases(appwrite);

  const items = await databases.listDocuments(
    DatabaseId,
    Collection.PlaidItems,
    [Query.equal('user_id', [userId])]
  );

  const firstItem = items.documents[0];
  const request = {
    access_token: firstItem.access_token,
    cursor: null,
  };
  const response = await plaid.transactionsSync(request); // --> no error
  log(response.data); // --> error happens 

👍 Expected behavior

I should be able to access the property without having a 500 error.

👎 Actual Behavior

Attempting to access the response.data prop gives a An internal curl error has occurred within the executor! Error Msg: Http invalid protocol\nError Code: 500 error.

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Linux

🧱 Your Environment

Appwrite Node SDK v^13.0.0,

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@logan-waite logan-waite added the bug Something isn't working label Oct 24, 2023
@Haimantika
Copy link
Contributor

Haimantika commented Oct 26, 2023

Hi @logan-waite appreciate you bringing this up and having patience. I have asked the team for more details, will keep you updated here.

@Haimantika Haimantika self-assigned this Oct 26, 2023
@Haimantika
Copy link
Contributor

@logan-waite what endpoint have you set for the SDK inside of his function? It should be https://cloud

@logan-waite
Copy link
Author

This is what I call at the top of the main body of my function:

function createAppwriteSdk({ jwt } = { jwt: false }) {
  const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID);

  if (jwt) {
    return client.setJWT(process.env.APPWRITE_USER_JWT);
  } else {
    return client.setKey(process.env.APPWRITE_API_KEY);
  }
}

What is odd to me is that I call similar third-party endpoints in different parts of the function, and I don't have a problem with those.

@stnguyen90 stnguyen90 added the product / functions Fixes and upgrades for the Appwrite Functions. label Nov 2, 2023
@stnguyen90
Copy link
Contributor

@logan-waite, maybe there's a circular reference or something. Could you try making sure to pass a string to log()?

@logan-waite
Copy link
Author

When I run the object through JSON.stringify, the function just silently fails.

@logan-waite
Copy link
Author

Looks like if I remove all my log statements, I'm able to get the data back. Do you know if there are plans to make the log function more robust than just taking strings?

@stnguyen90
Copy link
Contributor

@logan-waite,

When I run the object through JSON.stringify, the function just silently fails.

This will also have a problem with circular references.

Do you know if there are plans to make the log function more robust than just taking strings?

It's safest to only pass strings, but technically, you can pass other things. I would have expected the log call to throw an exception and then the function would return 500 failed.

@stnguyen90
Copy link
Contributor

So, I just tested a function like this:

export default async ({ req, res, log, error }) => {
  const a = {};
  const b = {a: a};
  a.b = b;

  log(a);

  // `res.json()` is a handy helper for sending JSON
  return res.json({
    motto: 'Build like a team of hundreds_',
    learn: 'https://appwrite.io/docs',
    connect: 'https://appwrite.io/discord',
    getInspired: 'https://builtwith.appwrite.io',
  });
};

and it did throw an error:

image

Maybe there's something else with that response.data of yours. Or maybe there's too much data to log (all the logs are limited to less than 1 million characters)?

@stnguyen90 stnguyen90 added the question Further information is requested label Apr 25, 2024
@stnguyen90 stnguyen90 self-assigned this Apr 25, 2024
Copy link

github-actions bot commented May 3, 2024

This issue has been labeled as a 'question', indicating that it requires additional information from the requestor. It has been inactive for 7 days. If no further activity occurs, this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label May 3, 2024
Copy link

This issue has been closed due to inactivity. If you still require assistance, please provide the requested information.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions. question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

3 participants