louislam/dockge · info · ValidationError
Stack name must be a string
Error message
Stack name must be a string
What it means
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.
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
Example fix
// before
agentSocket.emit("getStack", stackObj, cb);
// after
agentSocket.emit("getStack", stackObj.name, cb); Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof stackName !== "string") {
throw new Error("getStack requires a string stack name");
} Type guard
function isStackName(v: unknown): v is string {
return typeof v === "string" && v.length > 0;
} Try / catch
agentSocket.emit("getStack", stackName, (res) => {
if (!res.ok && res.msg === "Stack name must be a string") {
// correct the payload type and retry
}
}); Prevention
- Resolve the stack name before emitting (avoid undefined)
- Pass stack.name, not the stack object
- Validate payload types in client-side wrappers
When it happens
Trigger: Client emits 'getStack' with a non-string first argument: undefined (argument omitted), a number, an object like {name:...}, or null.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Name must be a string
- Command must be a number.
- Command must be a string.
- Data must be an object
- dockerRunCommand must be a string
AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31).
Data as JSON: /api/errors/b7d6ab43fcd49beb.
Report an issue: GitHub.
Appendix: source
Thrown at backend/agent-socket-handlers/docker-socket-handler.ts:75
server.sendStackList();
callbackResult({
ok: true,
msg: "Deleted",
msgi18n: true,
}, callback);
} catch (e) {
callbackError(e, callback);
}
});
agentSocket.on("getStack", async (stackName : unknown, callback) => {
try {
checkLogin(socket);
if (typeof(stackName) !== "string") {
throw new ValidationError("Stack name must be a string");
}
const stack = await Stack.getStack(server, stackName);
if (stack.isManagedByDockge) {
stack.joinCombinedTerminal(socket);
}
callbackResult({
ok: true,
stack: await stack.toJSON(socket.endpoint),
}, callback);
} catch (e) {
callbackError(e, callback);
}
});
// requestStackListView on GitHub (pinned to f809ae192b)