{"record":{"id":"58c889785dcca8a4","repo":"floci-io/floci","slug":"validationerror-58c889","errorCode":"ValidationError","errorMessage":"Stack with id {} does not exist","messagePattern":"Stack with id (.+?) does not exist","errorType":"exception","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationService.java","lineNumber":129,"sourceCode":"\n    /**\n     * Sets a stack's termination protection (CloudFormation {@code UpdateTerminationProtection}).\n     * Returns the stack so the caller can echo its {@code StackId}.\n     */\n    public Stack updateTerminationProtection(String stackName, boolean enabled, String region) {\n        Stack stack = getStackOrThrow(stackName, region);\n        stack.setEnableTerminationProtection(enabled);\n        persistStack(stack);\n        return stack;\n    }\n\n    // ── DescribeStacks ────────────────────────────────────────────────────────\n\n    public List<Stack> describeStacks(String stackName, String region) {\n        if (stackName != null && !stackName.isBlank()) {\n            Stack stack = resolveStackForDescribe(stackName, region);\n            if (stack == null) {\n                throw new AwsException(\"ValidationError\",\n                        \"Stack with id \" + stackName + \" does not exist\", 400);\n            }\n            return List.of(stack);\n        }\n        return stacks.values().stream()\n                .filter(s -> region.equals(s.getRegion()))\n                .sorted(Comparator.comparing(Stack::getCreationTime))\n                .toList();\n    }\n\n    // ── CreateChangeSet ───────────────────────────────────────────────────────\n\n    public ChangeSet createChangeSet(String stackName, String changeSetName, String changeSetType,\n                                     String templateBody, String templateUrl,\n                                     Map<String, String> parameters, List<String> capabilities,\n                                     Map<String, String> tags, String region) {\n        String resolvedTemplate = resolveTemplate(templateBody, templateUrl);\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationService.java#L111-L147","documentation":"DescribeStacks was called with a non-blank StackName (or stack id) that resolves to no stack in this region — resolveStackForDescribe returned null. Real AWS also answers ValidationError ('Stack with id ... does not exist') here, so Floci mirrors it. A blank StackName does not throw; it lists all stacks.","triggerScenarios":"aws cloudformation describe-stacks --stack-name my-stack where my-stack was never created, was deleted (and purged), or exists in a different region; passing a stack id after the emulator's storage was reset.","commonSituations":"Scripts assuming a stack exists after a failed create; wrong AWS_DEFAULT_REGION / endpoint region against the emulator; persistence wiped (memory storage mode restart); typo in the stack name.","solutions":["List what actually exists: aws cloudformation describe-stacks (no name) or list-stacks, and compare names.","Check the region matches where the stack was created (the emulator keys stacks per region).","If the stack was recently deleted, it is gone immediately in Floci (expired stacks are purged) — recreate it.","For scripts, first call list-stacks and branch on presence instead of assuming."],"exampleFix":"# before\naws cloudformation describe-stacks --stack-name my-stak   # typo\n# after\naws cloudformation list-stacks --query 'StackSummaries[].StackName'\naws cloudformation describe-stacks --stack-name my-stack","handlingStrategy":"try-catch","validationCode":"const exists = await cfn.listStacks({StackStatusFilter: ['CREATE_COMPLETE','UPDATE_COMPLETE','UPDATE_ROLLBACK_COMPLETE']})\n    .StackSummaries.some(s => s.StackName === name);\nif (!exists) return; // nothing to describe","typeGuard":"const stackExists = (summaries, name) => summaries.some(s => s.StackName === name);","tryCatchPattern":"try {\n    const d = await cfn.describeStacks({StackName: name}).promise();\n} catch (e) {\n    if (e.code === 'ValidationError' && /does not exist/.test(e.message)) return null;\n    throw e;\n}","preventionTips":["Always gate describe/delete flows on list-stacks output.","Pin the emulator region explicitly (AWS_DEFAULT_REGION) so lookups match creation region."],"tags":["cloudformation","describe-stacks","not-found","aws-cli"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}