{"record":{"id":"f47a54cbdddd0000","repo":"floci-io/floci","slug":"resourcenotfoundexception-f47a54","errorCode":"ResourceNotFoundException","errorMessage":"Backup selection not found in plan: {planId}","messagePattern":"Backup selection not found in plan: (.+?)","errorType":"exception","errorClass":"AwsException","httpStatus":404,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/backup/BackupService.java","lineNumber":179,"sourceCode":"        String selectionId = UUID.randomUUID().toString();\n        BackupSelection selection = new BackupSelection();\n        selection.setSelectionId(selectionId);\n        selection.setSelectionName(selectionName);\n        selection.setBackupPlanId(planId);\n        selection.setIamRoleArn(iamRoleArn);\n        selection.setResources(resources);\n        selection.setNotResources(notResources);\n        selection.setCreationDate(Instant.now().getEpochSecond());\n        selection.setCreatorRequestId(creatorRequestId);\n        selectionStore.put(selectionId, selection);\n        return selection;\n    }\n\n    public BackupSelection getBackupSelection(String planId, String selectionId) {\n        BackupSelection sel = selectionStore.get(selectionId)\n                .orElseThrow(() -> new AwsException(\"ResourceNotFoundException\", \"Backup selection not found: \" + selectionId, 404));\n        if (!planId.equals(sel.getBackupPlanId())) {\n            throw new AwsException(\"ResourceNotFoundException\", \"Backup selection not found in plan: \" + planId, 404);\n        }\n        return sel;\n    }\n\n    public void deleteBackupSelection(String planId, String selectionId) {\n        getBackupSelection(planId, selectionId);\n        selectionStore.delete(selectionId);\n    }\n\n    public List<BackupSelection> listBackupSelections(String planId) {\n        return selectionStore.scan(k -> true).stream()\n                .filter(s -> planId.equals(s.getBackupPlanId()))\n                .toList();\n    }\n\n    // ── Job ────────────────────────────────────────────────────────────────────\n\n    public BackupJob startBackupJob(String vaultName, String resourceArn, String iamRoleArn,","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/backup/BackupService.java#L161-L197","documentation":"Thrown by getBackupSelection when the selection exists in the store but belongs to a different plan than the one in the request. AWS Backup scopes selections under their plan ARN, so a plan/selection mismatch is reported as ResourceNotFoundException (HTTP 404) — the pair simply does not exist together.","triggerScenarios":"Calling GetBackupSelection (or DeleteBackupSelection, which delegates to it) with a selectionId that exists but whose BackupPlanId differs from the requested planId.","commonSituations":"Copy-pasting IDs between test fixtures so selection and plan ids cross wires; enumerating all selections globally and calling them against the wrong plan; truncation or typo in one of the two identifiers.","solutions":["Use ListBackupSelections on the plan to get IDs guaranteed to match, then retry with that plan/selection pair","Verify both identifiers came from the same creation flow — regenerate them if unsure"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"boolean pairExists = backup.listBackupSelections(ListBackupSelectionsRequest.builder()\n    .backupPlanId(planId).build()).backupSelectionsList().stream()\n    .anyMatch(s -> selectionId.equals(s.selectionId()));\nif (!pairExists) throw new NoSuchResourceException(planId + \"/\" + selectionId);","typeGuard":null,"tryCatchPattern":"catch (ResourceNotFoundException e) { re-enumerate selections under the plan and correct the stale id; }","preventionTips":["Always obtain selection IDs from ListBackupSelections of the same plan","Never pair a selection ID from one fixture with a plan ID from another"],"tags":["backup","selection","not-found","identifier-mismatch","aws-emulator"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}