-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
HTTP Request Node - "TypeError: Converting circular structure to JSON" #3089
Comments
Hey @mark-monteiro, That doesn't look good, I have just given the node you provided a quick run and I have not been able to reproduce it. Is there more to the workflow? Once we can reproduce the issue we will be able to get it fixed. |
@Joffcom The node was in an workflow with more nodes, but I copied it to a new workflow and executed it on it's own and still got the same error. Here's is an export of the simplified workflow that produces the error for me. {
"name": "Error Repro",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"requestMethod": "PATCH",
"url": "=https://www.googleapis.com/upload/drive/v3/files/{{$json[\"googleDriveFileId\"]}}",
"allowUnauthorizedCerts": true,
"options": {
"fullResponse": true
},
"bodyParametersUi": {
"parameter": [
{
"name": "mimeType",
"value": "application/vnd.google-apps.spreadsheet"
}
]
},
"headerParametersUi": {
"parameter": [
{
"name": "X-Upload-Content-Type",
"value": "={{$binary.attachment_0.mimeType}}"
}
]
},
"queryParametersUi": {
"parameter": [
{
"name": "uploadType",
"value": "resumable"
}
]
}
},
"name": "Start Upload To Drive (Metadata)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
460,
300
],
"notes": "Details on how xlsx file is converted to Google Sheet: https://stackoverflow.com/a/36957953/1988326"
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Start Upload To Drive (Metadata)",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"id": 10
} Not sure if it will help, but here is the full workflow this node was originally in: {
"name": "SOS Export To Google Drive",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
-440,
460
]
},
{
"parameters": {
"format": "resolved",
"options": {
"customEmailConfig": "[[\"UNSEEN\"], [\"FROM\", \"[email protected]\"], [\"TO\", \"[email protected]\"]]",
"allowUnauthorizedCerts": true
}
},
"name": "IMAP Email - SOS Item Export",
"type": "n8n-nodes-base.emailReadImap",
"typeVersion": 1,
"position": [
-180,
460
],
"credentials": {
"imap": {
"id": "3",
"name": "Senti IMAP account"
}
}
},
{
"parameters": {
"functionCode": "// Code here will run once per input item.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.functionItem\n// Tip: You can use luxon for dates and $jmespath for querying JSON structures\n\n// This list of valid mime types comes from the 'about' endpoint in the Google Workspace API in the 'importFormats' array\n// See: https://developers.google.com/drive/api/guides/manage-uploads#import_to_google_docs_types\n// and: https://developers.google.com/drive/api/v3/reference/about/get?apix_params=%7B%22fields%22%3A%22importFormats%22%7D\nconst validMimeTypes = [\n \"text/tab-separated-values\",\n \"application/vnd.ms-excel.sheet.macroenabled.12\",\n \"application/vnd.ms-excel\",\n \"application/vnd.oasis.opendocument.spreadsheet\",\n \"application/x-vnd.oasis.opendocument.spreadsheet\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.template\",\n \"application/vnd.ms-excel.template.macroenabled.12\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \"text/csv\"\n];\n\n// Validate the file mime type of the input file\nconst fileMimeType = getBinaryData().attachment_0.mimeType;\nif (validMimeTypes.indexOf(fileMimeType) === -1) {\n throw new Error(\"Invalid mime type: \" + fileMimeType);\n}\n\n// Add a new field called 'googleDriveFileId' to the JSON of the item\nif (item.subject === \"Item Export for Senti Solutions Inc\") {\n item.googleDriveFileId = \"1-7wJ8gHyP-XxKXSi6KQO9HRlCuK_UWtSlt1296qVZRo\";\n} else if (item.subject === \"Vendor Export for Senti Solutions Inc\") {\n item.googleDriveFileId = \"1WwFLfoG19eyiUu9SFc6okub8C1v4ZyPbWT2u07p5er4\";\n} else if (item.subject === \"Vendor-Item Catalog Export for Senti Solutions Inc\") {\n item.googleDriveFileId = \"1Es1-4lAxyr1BOaWVLkoGUyVLVNtWOtF1l9OtxhtXg_0\";\n} else {\n throw new Error(\"Unsupported email subject line:\" + item.subject);\n}\n\n// Return the modified item\nreturn item;"
},
"name": "Set Google Drive File Id",
"type": "n8n-nodes-base.functionItem",
"typeVersion": 1,
"position": [
60,
640
]
},
{
"parameters": {
"mode": "mergeByIndex",
"join": "inner"
},
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 1,
"position": [
500,
640
]
},
{
"parameters": {
"authentication": "oAuth2",
"requestMethod": "PATCH",
"url": "=https://www.googleapis.com/upload/drive/v3/files/{{$json[\"googleDriveFileId\"]}}",
"allowUnauthorizedCerts": true,
"options": {
"fullResponse": true
},
"bodyParametersUi": {
"parameter": [
{
"name": "mimeType",
"value": "application/vnd.google-apps.spreadsheet"
}
]
},
"headerParametersUi": {
"parameter": [
{
"name": "X-Upload-Content-Type",
"value": "={{$binary.attachment_0.mimeType}}"
}
]
},
"queryParametersUi": {
"parameter": [
{
"name": "uploadType",
"value": "resumable"
}
]
}
},
"name": "Start Upload To Drive (Metadata)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
280,
740
],
"credentials": {
"oAuth2Api": {
"id": "7",
"name": "Google Drive Update API"
}
},
"notes": "Details on how xlsx file is converted to Google Sheet: https://stackoverflow.com/a/36957953/1988326"
},
{
"parameters": {
"authentication": "oAuth2",
"requestMethod": "PATCH",
"url": "={{$json[\"headers\"][\"location\"]}}",
"jsonParameters": true,
"options": {
"bodyContentType": "raw"
},
"sendBinaryData": true,
"binaryPropertyName": "attachment_0"
},
"name": "Finish Upload To Drive (File Content)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
720,
640
],
"credentials": {
"oAuth2Api": {
"id": "7",
"name": "Google Drive Update API"
}
},
"notes": "Details on how xlsx file is converted to Google Sheet: https://stackoverflow.com/a/36957953/1988326"
},
{
"parameters": {
"mode": "mergeByIndex",
"join": "inner"
},
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 1,
"position": [
300,
200
],
"disabled": true
},
{
"parameters": {
"authentication": "oAuth2",
"requestMethod": "POST",
"url": "https://www.googleapis.com/upload/drive/v3/files",
"jsonParameters": true,
"options": {
"bodyContentType": "json",
"fullResponse": true
},
"bodyParametersJson": "={\n \"name\": \"{{$binary.attachment_0.fileName}}\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\",\n \"parents\": [\"11neNYN3IHeCLE_MAOcrVKXkB5lnVZD3b\"]\n}",
"headerParametersJson": "={ \"X-Upload-Content-Type\": \"{{$binary.attachment_0.mimeType}}\" }",
"queryParametersJson": "{ \"uploadType\": \"resumable\" }"
},
"name": "Start New Upload To Drive (Metadata)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
60,
200
],
"credentials": {
"oAuth2Api": {
"id": "7",
"name": "Google Drive Update API"
}
},
"disabled": true,
"notes": "Execute to create new files. It is required that the file is created via this auth token so that the token also has permission to update the file at a later date"
},
{
"parameters": {
"authentication": "oAuth2",
"requestMethod": "PUT",
"url": "={{$json[\"headers\"][\"location\"]}}",
"allowUnauthorizedCerts": true,
"jsonParameters": true,
"options": {
"bodyContentType": "raw"
},
"sendBinaryData": true,
"binaryPropertyName": "attachment_0"
},
"name": "Finish New Upload To Drive (File Content)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
500,
200
],
"credentials": {
"oAuth2Api": {
"id": "7",
"name": "Google Drive Update API"
}
},
"disabled": true,
"notes": "Details on how xlsx file is converted to Google Sheet: https://stackoverflow.com/a/36957953/1988326"
},
{
"parameters": {
"spaceId": "spaces/AAAATTakZLA",
"messageUi": {
"text": "=Starting import of SOS Inventory data into Google Drive for file {{$binary.attachment_0.fileName}}"
},
"additionalFields": {}
},
"name": "Google Chat Initial Message",
"type": "n8n-nodes-base.googleChat",
"typeVersion": 1,
"position": [
60,
460
],
"credentials": {
"googleApi": {
"id": "8",
"name": "Google Chat Service Account"
}
}
},
{
"parameters": {
"spaceId": "spaces/AAAATTakZLA",
"messageUi": {
"text": "=File successfully updated on Google Drive: <https://docs.google.com/spreadsheets/d/{{$json[\"id\"]}}|{{$json[\"name\"]}}>"
},
"additionalFields": {}
},
"name": "Google Chat Complete Message",
"type": "n8n-nodes-base.googleChat",
"typeVersion": 1,
"position": [
940,
640
],
"credentials": {
"googleApi": {
"id": "8",
"name": "Google Chat Service Account"
}
}
},
{
"parameters": {},
"name": "Error Trigger",
"type": "n8n-nodes-base.errorTrigger",
"typeVersion": 1,
"position": [
-180,
980
]
},
{
"parameters": {
"spaceId": "spaces/AAAATTakZLA",
"messageUi": {
"text": "=An error occurred in n8n workflow '{{$json[\"workflow\"][\"name\"]}}' in node '{{$json[\"execution\"][\"lastNodeExecuted\"]}}': {{$json[\"execution\"][\"url\"]}}"
},
"additionalFields": {}
},
"name": "Google Chat Error Message",
"type": "n8n-nodes-base.googleChat",
"typeVersion": 1,
"position": [
20,
980
],
"credentials": {
"googleApi": {
"id": "8",
"name": "Google Chat Service Account"
}
}
}
],
"connections": {
"IMAP Email - SOS Item Export": {
"main": [
[
{
"node": "Start New Upload To Drive (Metadata)",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
},
{
"node": "Set Google Drive File Id",
"type": "main",
"index": 0
},
{
"node": "Google Chat Initial Message",
"type": "main",
"index": 0
}
]
]
},
"Set Google Drive File Id": {
"main": [
[
{
"node": "Start Upload To Drive (Metadata)",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Finish Upload To Drive (File Content)",
"type": "main",
"index": 0
}
]
]
},
"Start Upload To Drive (Metadata)": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Finish New Upload To Drive (File Content)",
"type": "main",
"index": 0
}
]
]
},
"Start New Upload To Drive (Metadata)": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"Finish Upload To Drive (File Content)": {
"main": [
[
{
"node": "Google Chat Complete Message",
"type": "main",
"index": 0
}
]
]
},
"Error Trigger": {
"main": [
[
{
"node": "Google Chat Error Message",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"saveExecutionProgress": "DEFAULT",
"errorWorkflow": "8"
},
"id": 8
} Perhaps there is something specific with my environment that is causing this? Here is the version: "3"
services:
n8n:
image: n8nio/n8n
container_name: n8n
labels:
com.centurylinklabs.watchtower.enable: true
restart: always
ports:
- '5675:5675'
volumes:
- xxxxxxxxxxx:/home/node/.n8n
- xxxxxxxxxxx:/files
environment:
- TZ=Canada/Eastern
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_HOST=xxxxxxxxxxxxxxx
- N8N_PORT=5675
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_TUNNEL_URL=xxxxxxxxxxxxxxx
- N8N_LOG_LEVEL=debug
# Allows importing built-in modules to function nodes
# - NODE_FUNCTION_ALLOW_BUILTIN=*
env_file:
- credentials.env # This file should contain N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD |
Hey @mark-monteiro, I have tried to reproduce using a cut down version of your main workflow where instead of an email I have done an HTTP Get on a test CSV file. I have then set item.subject to be the first entry in your If block and it oddly enough runs with no issue. Are you able to try the workflow below (changing the googleDriveFileId to a test one and seeing if you get the same issue? I am wondering if maybe the error is only happening with certain file formats.
|
@Joffcom That didn't seem to help :/ I'm not sure how likely it is that this error depends on the specific file being used. On my instance I'm able to reproduce this with a very simple workflow with only a single HTTP request node that has no reference to the file at all: |
Did a bit of digging and it looks like this same problem is solved in winston by using Perhaps the same fix could be applied here? n8n/packages/cli/src/Logger.ts Line 36 in 7625421
Seems like a good option, I think in general it is best practice to make sure your logging infrastructure can never throw exceptions |
@mark-monteiro it is a good idea but I am still not sure what is actually causing it, I have been unable to reproduce it on a few different installs so it would be nice to work out what is causing it. I will have another poke at it in the morning to what I can find. |
Thanks for looking into it. Errors that can't be reproduced are the worst 😩 I did some more searching into old issues and I found #2256 that appears to have the same error as me in an HTTP Request node:
It looks like some other problems were resolved in that issue but this specific error was also not reproducible back then (Sept 2011). I double checked in my execution history and it turns out the error was also present a few days before I updated to the latest version. So it doesn't look like this issue is specific to the latest release, sorry for the confusion. |
@Joffcom I was able to narrow down exactly where this error is coming from 🎉 I had a hunch that this line was causing the logger error. The What I ended up doing was going into a shell in my docker container with
As you can see, it turns out the underlying issue was that I was getting a So I think there's two issues here:
|
That is some good work and I should be able to reproduce that one by letting the token expire. The problem with the credential will likely be the access type parameter not being set to offline. I will have a play, a lot of the time the data internally is json so the stringify method should be fine so I suspect somewhere along the way there there is something not being set as a json object. Hopefully I will have a proper soon. |
This should be fixed with #3583. If this error comes up again I'll re-open this issue. |
Describe the bug
After updating tot he latest version, the HTTP Request node in my workflow now always crashes with the error message "Workflow execution process did crash for an unknown reason!"
The log file on the server has an error message
TypeError: Converting circular structure to JSON
. The relevant log and stack trace has been included below.To Reproduce
Steps to reproduce the behavior:
Http request node configuration:
Expected behavior
Node should not crash with an unhandled exception.
Environment (please complete the following information):
Additional context
Logs + stacktrace:
The text was updated successfully, but these errors were encountered: