{"record":{"id":"56006b1e0e3f72f8","repo":"floci-io/floci","slug":"nosuchfunctionexists","errorCode":"NoSuchFunctionExists","errorMessage":"The specified function does not exist.","messagePattern":"The specified function does not exist\\.","errorType":"exception","errorClass":"AwsException","httpStatus":404,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontService.java","lineNumber":786,"sourceCode":"\n    // ── CloudFront Functions ──────────────────────────────────────────────────\n\n    public synchronized CloudFrontFunction createFunction(CloudFrontFunction fn) {\n        fn.setStage(\"DEVELOPMENT\");\n        fn.setStatus(\"UNPUBLISHED\");\n        fn.setEtag(UUID.randomUUID().toString());\n        fn.setCreatedTime(Instant.now());\n        fn.setLastModifiedTime(Instant.now());\n        functionStore.put(fn.getName(), fn);\n        return fn;\n    }\n\n    public CloudFrontFunction describeFunction(String name, String stage) {\n        CloudFrontFunction fn = functionStore.get(name).orElseThrow(() ->\n                new AwsException(\"NoSuchFunctionExists\",\n                        \"The specified function does not exist.\", 404));\n        if (stage != null && !stage.isEmpty() && !fn.getStage().equals(stage)) {\n            throw new AwsException(\"NoSuchFunctionExists\",\n                    \"The specified function does not exist.\", 404);\n        }\n        return fn;\n    }\n\n    public synchronized CloudFrontFunction updateFunction(String name, String ifMatch,\n                                                          CloudFrontFunction updated) {\n        CloudFrontFunction existing = describeFunction(name, null);\n        if (!existing.getEtag().equals(ifMatch)) {\n            throw new AwsException(\"InvalidIfMatchVersion\",\n                    \"The If-Match version is missing or not valid for the resource.\", 400);\n        }\n        updated.setName(name);\n        updated.setStage(existing.getStage());\n        updated.setStatus(existing.getStatus());\n        updated.setEtag(UUID.randomUUID().toString());\n        updated.setCreatedTime(existing.getCreatedTime());\n        updated.setLastModifiedTime(Instant.now());","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontService.java#L768-L804","documentation":"CloudFrontService.describeFunction throws NoSuchFunctionExists (HTTP 404) when no function is stored under the given Name, or when a Stage parameter was supplied and the stored function's stage does not match it. It is the standard not-found signal for DescribeFunction and also the lookup primitive reused by updateFunction, publishFunction, and deleteFunction, so those operations surface it too when the name is wrong.","triggerScenarios":"DescribeFunction with a name never created, deleted, or misspelled; or DescribeFunction with Stage=\"LIVE\" when the function is still in \"DEVELOPMENT\" stage (publishFunction is what promotes it to LIVE). Calling UpdateFunction/PublishFunction/DeleteFunction on a nonexistent name hits the same orElseThrow.","commonSituations":"Reading a function before it is published and expecting LIVE metadata; using the ARN or alias instead of the bare Name; test ordering where the create call failed earlier so later steps 404; emulator storage reset between test phases losing in-memory functions.","solutions":["Create the function first with CreateFunction and verify success before calling Describe/Update/Publish.","If querying with Stage, either omit it or match the real stage: use \"DEVELOPMENT\" before publishFunction, \"LIVE\" after.","Pass the plain function Name (not the ARN) exactly as it was set at creation.","If the function should exist, check ListFunctions to confirm what names and stages are actually stored."],"exampleFix":"// before\ncloudFront.describeFunction(req -> req.name(\"my-fn\").stage(\"LIVE\")); // 404 pre-publish\n\n// after\ncloudFront.describeFunction(req -> req.name(\"my-fn\")); // or publish first, then query LIVE","handlingStrategy":"try-catch","validationCode":"boolean functionExists(CloudFrontClient client, String name) {\n    return client.listFunctions(r -> r.build()).functionList().items().stream()\n            .anyMatch(f -> f.name().equals(name));\n}","typeGuard":null,"tryCatchPattern":"try {\n    return client.describeFunction(r -> r.name(name).stage(stage));\n} catch (NoSuchFunctionExists e) {\n    if (stage != null) { // maybe just wrong stage; retry without it\n        return client.describeFunction(r -> r.name(name));\n    }\n    throw e;\n}","preventionTips":["Create functions before any describe/update/publish flow references them.","Query without Stage unless you specifically need LIVE metadata.","Use ListFunctions to verify names before acting on them in scripts."],"tags":["cloudfront","functions","not-found","aws-emulator"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}