floci-io/floci · error · AwsException
InternalFailure
InternalFailure
Error message
Invalid EventBus policy in {source}: {message} What it means
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.
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceProvisioner.java:3177
}
}
private JsonNode resolveEventBusPolicy(JsonNode props, CloudFormationTemplateEngine engine) {
if (props == null || !props.has("Policy") || props.get("Policy").isNull()) {
return JsonNodeFactory.instance.nullNode();
}
return engine.resolveNode(props.get("Policy"));
}
private JsonNode parseEventBusPolicy(String policy, String source) {
if (policy == null) {
return JsonNodeFactory.instance.nullNode();
}
try {
JsonNode parsed = objectMapper.readTree(policy);
return parsed != null ? parsed : JsonNodeFactory.instance.nullNode();
} catch (Exception e) {
throw new AwsException("InternalFailure",
"Invalid EventBus policy in " + source + ": " + e.getMessage(), 500);
}
}
private void recordEventBusManagedPolicy(StackResource resource, JsonNode policy) {
try {
resource.getAttributes().put(EVENT_BUS_MANAGED_POLICY_ATTR,
objectMapper.writeValueAsString(policy));
} catch (Exception e) {
throw new AwsException("InternalFailure",
"Failed to store EventBus managed-policy metadata: " + e.getMessage(), 500);
}
}
private AwsException unsupportedEventBusMutableUpdate() {
return new AwsException("ValidationError",
"Updating AWS::Events::EventBus Description, Tags, or Policy is not supported "
+ "until transactional rollback is available.", 400);View on GitHub (pinned to 62ff490619)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
cfnClient.updateStack(req);
} catch (AwsServiceException e) {
if ("InternalFailure".equals(e.awsErrorDetails().errorCode())
&& e.getMessage() != null && e.getMessage().contains("Invalid EventBus policy")) {
// emulator-side state issue: recreate the bus resource instead of retrying blindly
log.warn("Corrupt bus policy state; recreating EventBus resource", e);
recreateEventBusResource(stack);
} else {
throw e;
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/4846f502b1ff39a1.
Report an issue: GitHub.