{"record":{"id":"b7d6ab43fcd49beb","repo":"louislam/dockge","slug":"stack-name-must-be-a-string","errorCode":null,"errorMessage":"Stack name must be a string","messagePattern":"Stack name must be a string","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"info","filePath":"backend/agent-socket-handlers/docker-socket-handler.ts","lineNumber":75,"sourceCode":"\n                server.sendStackList();\n                callbackResult({\n                    ok: true,\n                    msg: \"Deleted\",\n                    msgi18n: true,\n                }, callback);\n\n            } catch (e) {\n                callbackError(e, callback);\n            }\n        });\n\n        agentSocket.on(\"getStack\", async (stackName : unknown, callback) => {\n            try {\n                checkLogin(socket);\n\n                if (typeof(stackName) !== \"string\") {\n                    throw new ValidationError(\"Stack name must be a string\");\n                }\n\n                const stack = await Stack.getStack(server, stackName);\n\n                if (stack.isManagedByDockge) {\n                    stack.joinCombinedTerminal(socket);\n                }\n\n                callbackResult({\n                    ok: true,\n                    stack: await stack.toJSON(socket.endpoint),\n                }, callback);\n            } catch (e) {\n                callbackError(e, callback);\n            }\n        });\n\n        // requestStackList","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/louislam/dockge/blob/f809ae192b571944ad773e9866d3e67064ae8043/backend/agent-socket-handlers/docker-socket-handler.ts#L57-L93","documentation":"The getStack agent socket handler validates stackName with typeof(stackName) !== 'string' and throws ValidationError('Stack name must be a string') otherwise, before Stack.getStack resolves the stack. It prevents malformed requests from reaching the stack lookup.","triggerScenarios":"Client emits 'getStack' with a non-string first argument: undefined (argument omitted), a number, an object like {name:...}, or null.","commonSituations":"Calling getStack before the stack list loads so the name variable is undefined; passing a numeric stack id; frontend state where the selected stack is an object rather than its name.","solutions":["Emit getStack with a plain string stack name","Ensure the stack name variable is defined/loaded before emitting","Fix callers that pass an object instead of the name field"],"exampleFix":"// before\nagentSocket.emit(\"getStack\", stackObj, cb);\n// after\nagentSocket.emit(\"getStack\", stackObj.name, cb);","handlingStrategy":"type-guard","validationCode":"if (typeof stackName !== \"string\") {\n    throw new Error(\"getStack requires a string stack name\");\n}","typeGuard":"function isStackName(v: unknown): v is string {\n    return typeof v === \"string\" && v.length > 0;\n}","tryCatchPattern":"agentSocket.emit(\"getStack\", stackName, (res) => {\n    if (!res.ok && res.msg === \"Stack name must be a string\") {\n        // correct the payload type and retry\n    }\n});","preventionTips":["Resolve the stack name before emitting (avoid undefined)","Pass stack.name, not the stack object","Validate payload types in client-side wrappers"],"tags":["validation","socket","typescript"],"backgroundTag":"invalid-argument-type","analyzedSha":"f809ae192b571944ad773e9866d3e67064ae8043","analyzedAt":"2026-08-31T19:13:50.919Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}