Circular Structure Error When Accessing Informatio...
# 🤝help
g
I am working on a project involving REST API calls to Firestore and OpenAI assistant APIs. The issue arises in the card flow, specifically when using a capture information card. After accessing it a few times, it generates a circular structure error, referencing internal code to which I don't have access. I have reviewed my code logic and found no apparent errors. However, since I do not have access to the internal logic of the capture information card, resolving this issue is challenging. Attached is a screenshot of the log for reference. Thank you in advance https://cdn.discordapp.com/attachments/1242930236207927418/1242930236455129118/image.png?ex=664fa07c&is=664e4efc&hm=e7aba95de2ca77df4e208e362ced29a2365f60ee5cd23232e97749fe2ab53d6e&
b
We had a similar problem it was a total nightmare to fix. My theory was that some json was being processed by an internal function, and that was causing the error. So 1 by 1 I started deleting sub objects event.xxx and workflow.xxx. And that was indeed the problem. In our case, the workflow.apiSlackRequest.response.request object was the culprit. The request property within the API response creates a circular reference, as shown below:
Copy code
{
  "apiSlackRequest": {
    "response": {
      "request": {
        "__sentry_xhr__": {
          "method": "GET",
          "url": "https://example.com/api",
          "body": null,
          "status_code": 200
        }
      }
    }
  }
}
I believe the circular reference arises in request -> res -> req -> request. To fix the issue, we deleted the problematic property response.request in a code execution card before proceeding. Here’s how:
Copy code
try {
  if (workflow.apiSlackRequest && workflow.apiSlackRequest.response) {
    delete workflow.apiSlackRequest.response.request; // Fix circular reference
    bp.logger.info('Deleted: response.request');
  }
} catch (error) {
  bp.logger.error('Error clearing response.request:', error.message);
}
c
Can you share with me the code snippet I can use to access firebase?
w
The problem occurs when you use the entire Axios response, but you should only take the 'data' field.
Copy code
const response = await axios.request(config);
return response.data;
3 Views