{"record":{"id":"4846f502b1ff39a1","repo":"floci-io/floci","slug":"internalfailure-4846f5","errorCode":"InternalFailure","errorMessage":"Invalid EventBus policy in {source}: {message}","messagePattern":"Invalid EventBus policy in (.+?): (.+?)","errorType":"exception","errorClass":"AwsException","httpStatus":500,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceProvisioner.java","lineNumber":3177,"sourceCode":"        }\n    }\n\n    private JsonNode resolveEventBusPolicy(JsonNode props, CloudFormationTemplateEngine engine) {\n        if (props == null || !props.has(\"Policy\") || props.get(\"Policy\").isNull()) {\n            return JsonNodeFactory.instance.nullNode();\n        }\n        return engine.resolveNode(props.get(\"Policy\"));\n    }\n\n    private JsonNode parseEventBusPolicy(String policy, String source) {\n        if (policy == null) {\n            return JsonNodeFactory.instance.nullNode();\n        }\n        try {\n            JsonNode parsed = objectMapper.readTree(policy);\n            return parsed != null ? parsed : JsonNodeFactory.instance.nullNode();\n        } catch (Exception e) {\n            throw new AwsException(\"InternalFailure\",\n                    \"Invalid EventBus policy in \" + source + \": \" + e.getMessage(), 500);\n        }\n    }\n\n    private void recordEventBusManagedPolicy(StackResource resource, JsonNode policy) {\n        try {\n            resource.getAttributes().put(EVENT_BUS_MANAGED_POLICY_ATTR,\n                    objectMapper.writeValueAsString(policy));\n        } catch (Exception e) {\n            throw new AwsException(\"InternalFailure\",\n                    \"Failed to store EventBus managed-policy metadata: \" + e.getMessage(), 500);\n        }\n    }\n\n    private AwsException unsupportedEventBusMutableUpdate() {\n        return new AwsException(\"ValidationError\",\n                \"Updating AWS::Events::EventBus Description, Tags, or Policy is not supported \"\n                        + \"until transactional rollback is available.\", 400);","sourceCodeStart":3159,"sourceCodeEnd":3195,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceProvisioner.java#L3159-L3195","documentation":"InternalFailure (HTTP 500) thrown while re-parsing a Policy string retrieved from the EventBridge service: objectMapper.readTree fails on content that is not valid JSON. It signals emulator-side state inconsistency — a stored bus policy that no longer parses — rather than a template error.","triggerScenarios":"During EventBus provisioning/update, the provisioner reads back a policy previously stored via PutPermission and readTree throws; typically after storage was mutated by another code path, persisted in a partially-written state, or a legacy non-JSON policy string exists from an older emulator version.","commonSituations":"Upgrading the emulator across versions where the policy storage format changed; concurrent stack operations writing the same bus; corrupted in-memory/persistent storage after an unclean shutdown.","solutions":["Delete and recreate the affected event bus (or the stack) so the policy is stored cleanly.","Restart the emulator (and clear persistent storage if the corruption survives restart).","Report the incident with the stored policy string — a 500 here indicates an emulator bug worth filing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    cfnClient.updateStack(req);\n} catch (AwsServiceException e) {\n    if (\"InternalFailure\".equals(e.awsErrorDetails().errorCode())\n            && e.getMessage() != null && e.getMessage().contains(\"Invalid EventBus policy\")) {\n        // emulator-side state issue: recreate the bus resource instead of retrying blindly\n        log.warn(\"Corrupt bus policy state; recreating EventBus resource\", e);\n        recreateEventBusResource(stack);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Avoid mixing raw PutPermission calls and CloudFrameless mutations of the same bus policy across emulator versions.","Recreate stacks after upgrading the emulator rather than updating in place when 500s appear.","Keep emulator state clean: don't hand-edit persistent storage files."],"tags":["cloudformation","eventbridge","internal-error","state-corruption"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}