fix(stacks): name the body field in the stack-create required error (#1289)

The create endpoint reads the new stack name from the body field
stackName, but a missing or non-string value returned "Stack name is
required and must be a string", which points at a value problem and
leaves anyone scripting against the stacks API unsure which field to
fix. Name the field in the message so the cause is unambiguous, and add
regression coverage for the missing and non-string cases.
This commit is contained in:
Anso
2026-06-02 19:53:45 -04:00
committed by GitHub
parent b2cae92a92
commit 653be3296b
2 changed files with 46 additions and 1 deletions
+1 -1
View File
@@ -618,7 +618,7 @@ stacksRouter.post('/', async (req: Request, res: Response) => {
try {
const { stackName } = req.body;
if (!stackName || typeof stackName !== 'string') {
return res.status(400).json({ error: 'Stack name is required and must be a string' });
return res.status(400).json({ error: "Field 'stackName' is required and must be a string" });
}
if (!isValidStackName(stackName)) {
return res.status(400).json({ error: 'Stack name can only contain alphanumeric characters, hyphens, and underscores' });