mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 07:36:40 +00:00
fix(stacks): harden stack management with security, validation, and logging (#520)
* fix(stacks): harden stack management with security fixes, validation alignment, and logging Validate WebSocket stack names with isValidStackName() to close a path-traversal gap on the /api/stacks/:stackName/logs WS endpoint. Align POST /api/stacks to use the canonical validator (allows underscores). Replace error: any catch blocks with error: unknown + type narrowing. Add cache invalidation to PUT /api/stacks/:stackName/env. Rename DELETE param from :name to :stackName for consistency. Add standard [Stacks] lifecycle logs and diagnostic [Stacks:debug] logs gated behind the Developer Mode toggle (with 5s TTL cache). Extract shared isDebugEnabled() and getErrorMessage() utilities. Frontend: roll back optimistic status on API failure, guard unsaved changes when switching stacks, pre-check duplicate names in App Store. * docs(settings): update Developer Mode description to mention debug diagnostics
This commit is contained in:
@@ -138,6 +138,19 @@ export function AppStoreView({ onDeploySuccess }: AppStoreViewProps) {
|
||||
toast.error("Stack name is required");
|
||||
return;
|
||||
}
|
||||
|
||||
// Pre-check for duplicate stack name
|
||||
try {
|
||||
const checkRes = await apiFetch('/stacks');
|
||||
if (checkRes.ok) {
|
||||
const existingStacks: string[] = await checkRes.json();
|
||||
if (existingStacks.includes(stackName.trim())) {
|
||||
toast.error(`A stack named "${stackName.trim()}" already exists. Choose a different name.`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch { /* proceed to deploy; backend will catch duplicates */ }
|
||||
|
||||
setIsDeploying(true);
|
||||
|
||||
const modifiedTemplate = { ...selectedTemplate };
|
||||
|
||||
Reference in New Issue
Block a user