feat(05): add update acknowledgment and pull error handling

1. Send "Updating <container>..." message immediately when update starts
   so user knows the command was received during long image pulls

2. Check pull response for rate limiting and other errors before
   continuing with update. Errors like "toomanyrequests" now show
   a proper error message instead of silently failing to update.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lucas Berger
2026-01-31 22:07:40 -05:00
parent 0839c44b50
commit d03e79cc7f
+138 -3
View File
@@ -1499,7 +1499,32 @@
}, },
{ {
"parameters": { "parameters": {
"jsCode": "// Build inspect command for the matched container\nconst containerId = $json.matches[0].Id;\nconst containerName = $json.matches[0].Name;\nconst chatId = $json.chatId;\n\nreturn {\n json: {\n cmd: `curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/${containerId}/json'`,\n containerId,\n containerName,\n chatId\n }\n};" "resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "=Updating <b>{{ $json.matches[0].Name }}</b>...",
"additionalFields": {
"parse_mode": "HTML"
}
},
"id": "telegram-send-update-started",
"name": "Send Update Started",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1560,
1200
],
"credentials": {
"telegramApi": {
"id": "telegram-credential",
"name": "Telegram API"
}
}
},
{
"parameters": {
"jsCode": "// Build inspect command for the matched container\n// Pass through original data from Match Update Container\nconst matchData = $('Check Update Match Count').item.json;\nconst containerId = matchData.matches[0].Id;\nconst containerName = matchData.matches[0].Name;\nconst chatId = matchData.chatId;\n\nreturn {\n json: {\n cmd: `curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/${containerId}/json'`,\n containerId,\n containerName,\n chatId\n }\n};"
}, },
"id": "code-build-inspect-cmd", "id": "code-build-inspect-cmd",
"name": "Build Inspect Command", "name": "Build Inspect Command",
@@ -1566,7 +1591,77 @@
}, },
{ {
"parameters": { "parameters": {
"jsCode": "// Build inspect image command to get the new image ID\nconst pullData = $('Build Pull Command').item.json;\nconst imageName = pullData.imageName;\n\nreturn {\n json: {\n cmd: `curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/${encodeURIComponent(imageName)}/json'`,\n imageName,\n currentImageId: pullData.currentImageId,\n currentVersion: pullData.currentVersion,\n containerConfig: pullData.containerConfig,\n hostConfig: pullData.hostConfig,\n networkSettings: pullData.networkSettings,\n containerName: pullData.containerName,\n containerId: pullData.containerId,\n chatId: pullData.chatId\n }\n};" "jsCode": "// Check pull response for errors\nconst stdout = $input.item.json.stdout || '';\nconst pullData = $('Build Pull Command').item.json;\nconst chatId = pullData.chatId;\nconst containerName = pullData.containerName;\n\n// Docker pull streams JSON objects, check for error messages\n// Rate limit error: {\"message\":\"toomanyrequests: ...\"}\n// Other errors: {\"message\":\"...\"}\nif (stdout.includes('\"message\"') && (stdout.includes('toomanyrequests') || stdout.includes('error') || stdout.includes('denied'))) {\n // Extract error message\n let errorMsg = 'Pull failed';\n try {\n const match = stdout.match(/\"message\"\\s*:\\s*\"([^\"]+)\"/); if (match) errorMsg = match[1];\n } catch (e) {}\n \n return {\n json: {\n pullError: true,\n chatId,\n text: `Failed to update ${containerName}: ${errorMsg.substring(0, 100)}`\n }\n };\n}\n\n// Success - pass through data for next node\nreturn {\n json: {\n pullError: false,\n imageName: pullData.imageName,\n currentImageId: pullData.currentImageId,\n currentVersion: pullData.currentVersion,\n containerConfig: pullData.containerConfig,\n hostConfig: pullData.hostConfig,\n networkSettings: pullData.networkSettings,\n containerName: pullData.containerName,\n containerId: pullData.containerId,\n chatId: pullData.chatId\n }\n};"
},
"id": "code-check-pull-response",
"name": "Check Pull Response",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2770,
1200
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "pull-error-check",
"leftValue": "={{ $json.pullError }}",
"rightValue": false,
"operator": {
"type": "boolean",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "if-pull-success",
"name": "Check Pull Success",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
2880,
1200
]
},
{
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.text }}",
"additionalFields": {
"parse_mode": "HTML"
}
},
"id": "telegram-send-pull-error",
"name": "Send Pull Error",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
3100,
1350
],
"credentials": {
"telegramApi": {
"id": "telegram-credential",
"name": "Telegram API"
}
}
},
{
"parameters": {
"jsCode": "// Build inspect image command to get the new image ID\nconst imageName = $json.imageName;\n\nreturn {\n json: {\n cmd: `curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/${encodeURIComponent(imageName)}/json'`,\n imageName,\n currentImageId: $json.currentImageId,\n currentVersion: $json.currentVersion,\n containerConfig: $json.containerConfig,\n hostConfig: $json.hostConfig,\n networkSettings: $json.networkSettings,\n containerName: $json.containerName,\n containerId: $json.containerId,\n chatId: $json.chatId\n }\n};"
}, },
"id": "code-build-inspect-image-cmd", "id": "code-build-inspect-image-cmd",
"name": "Build Image Inspect", "name": "Build Image Inspect",
@@ -2618,7 +2713,7 @@
], ],
[ [
{ {
"node": "Build Inspect Command", "node": "Send Update Started",
"type": "main", "type": "main",
"index": 0 "index": 0
} }
@@ -2644,6 +2739,17 @@
] ]
] ]
}, },
"Send Update Started": {
"main": [
[
{
"node": "Build Inspect Command",
"type": "main",
"index": 0
}
]
]
},
"Build Inspect Command": { "Build Inspect Command": {
"main": [ "main": [
[ [
@@ -2689,6 +2795,28 @@
] ]
}, },
"Pull Image": { "Pull Image": {
"main": [
[
{
"node": "Check Pull Response",
"type": "main",
"index": 0
}
]
]
},
"Check Pull Response": {
"main": [
[
{
"node": "Check Pull Success",
"type": "main",
"index": 0
}
]
]
},
"Check Pull Success": {
"main": [ "main": [
[ [
{ {
@@ -2696,6 +2824,13 @@
"type": "main", "type": "main",
"index": 0 "index": 0
} }
],
[
{
"node": "Send Pull Error",
"type": "main",
"index": 0
}
] ]
] ]
}, },