fix(10-07): add fuzzy matching to logs and fix chatId reference

- Send Logs Response now uses Prepare Text Logs Input for chatId
- Container logs sub-workflow uses .includes() for fuzzy matching
- Multiple match handling added with helpful error message
This commit is contained in:
Lucas Berger
2026-02-04 16:00:07 -05:00
parent 28f4c59d3f
commit 77c3d6543d
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -95,7 +95,7 @@
}, },
{ {
"parameters": { "parameters": {
"jsCode": "// Find container by name\nconst dockerOutput = $input.item.json.stdout;\nconst data = $('Check Container ID').item.json;\nconst containerName = data.containerName.toLowerCase();\n\n// Parse Docker response\nlet containers;\ntry {\n containers = JSON.parse(dockerOutput);\n} catch (e) {\n throw new Error('Failed to parse Docker response');\n}\n\n// Normalize name function\nfunction normalizeName(name) {\n return name\n .replace(/^\\//, '')\n .replace(/^(linuxserver[-_]|binhex[-_])/i, '')\n .toLowerCase();\n}\n\n// Find exact match\nconst container = containers.find(c => normalizeName(c.Names[0]) === containerName);\n\nif (!container) {\n throw new Error(`Container \"${containerName}\" not found`);\n}\n\nreturn {\n json: {\n ...data,\n containerId: container.Id,\n containerName: normalizeName(container.Names[0])\n }\n};" "jsCode": "// Find container by name (supports fuzzy matching)\nconst dockerOutput = $input.item.json.stdout;\nconst data = $('Check Container ID').item.json;\nconst containerName = data.containerName.toLowerCase();\n\n// Parse Docker response\nlet containers;\ntry {\n containers = JSON.parse(dockerOutput);\n} catch (e) {\n throw new Error('Failed to parse Docker response');\n}\n\n// Normalize name function\nfunction normalizeName(name) {\n return name\n .replace(/^\\//, '')\n .replace(/^(linuxserver[-_]|binhex[-_])/i, '')\n .toLowerCase();\n}\n\n// Find containers that match (fuzzy - includes search term)\nconst matches = containers.filter(c => normalizeName(c.Names[0]).includes(containerName));\n\nif (matches.length === 0) {\n throw new Error(`Container \"${containerName}\" not found`);\n}\n\nif (matches.length > 1) {\n const matchNames = matches.map(c => normalizeName(c.Names[0])).join(', ');\n throw new Error(`Multiple containers match \"${containerName}\": ${matchNames}`);\n}\n\nconst container = matches[0];\n\nreturn {\n json: {\n ...data,\n containerId: container.Id,\n containerName: normalizeName(container.Names[0])\n }\n};"
}, },
"id": "52dd705b-dd3b-4fdc-8484-276845857ad0", "id": "52dd705b-dd3b-4fdc-8484-276845857ad0",
"name": "Find Container", "name": "Find Container",
+1 -1
View File
@@ -1798,7 +1798,7 @@
"parameters": { "parameters": {
"resource": "message", "resource": "message",
"operation": "sendMessage", "operation": "sendMessage",
"chatId": "={{ $json.chatId }}", "chatId": "={{ $('Prepare Text Logs Input').item.json.chatId }}",
"text": "={{ $json.message }}", "text": "={{ $json.message }}",
"additionalFields": { "additionalFields": {
"parse_mode": "HTML" "parse_mode": "HTML"