{"record":{"id":"b381edb06824f369","repo":"floci-io/floci","slug":"internalerror","errorCode":"InternalError","errorMessage":"e.getMessage() != null ? e.getMessage() : \"Service invocation failed\"","messagePattern":"e\\.getMessage\\(\\) != null \\? e\\.getMessage\\(\\) : \"Service invocation failed\"","errorType":"http","errorClass":"AwsException","httpStatus":500,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/apigateway/AwsServiceRouter.java","lineNumber":175,"sourceCode":"                case \"dynamodb\" -> dynamoDbHandler.handle(action, requestBody, region);\n                case \"sqs\" -> sqsHandler.handle(action, requestBody, region);\n                case \"sns\" -> snsHandler.handle(action, requestBody, region);\n                case \"events\" -> eventBridgeHandler.handle(action, requestBody, region);\n                case \"ssm\" -> ssmHandler.handle(action, requestBody, region);\n                case \"kinesis\" -> kinesisHandler.handle(action, requestBody, region);\n                case \"logs\" -> logsHandler.handle(action, requestBody, region);\n                case \"monitoring\" -> metricsHandler.handle(action, requestBody, region);\n                case \"secretsmanager\" -> secretsManagerHandler.handle(action, requestBody, region);\n                case \"kms\" -> kmsHandler.handle(action, requestBody, region);\n                case \"cognito-idp\" -> cognitoHandler.handle(action, requestBody, region);\n                case \"acm\" -> acmHandler.handle(action, requestBody, region);\n                default -> throw new AwsException(\"UnknownService\",\n                        \"Unsupported AWS service integration: \" + service, 400);\n            };\n        } catch (AwsException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new AwsException(\"InternalError\",\n                    e.getMessage() != null ? e.getMessage() : \"Service invocation failed\", 500);\n        }\n    }\n\n    /**\n     * Dispatches an AWS query-protocol (form-encoded) integration request.\n     *\n     * <p>Used for {@code path/}-style integration URIs whose VTL request template renders an\n     * {@code application/x-www-form-urlencoded} body in the AWS query protocol, e.g.\n     * {@code Action=SendMessage&QueueUrl=...&MessageBody=...}. The {@code Action} parameter\n     * selects the operation, mirroring {@link io.github.hectorvent.floci.core.common.AwsQueryController}.\n     *\n     * @param service the AWS service name from the URI (e.g., \"sqs\")\n     * @param params  the parsed form parameters, including {@code Action}\n     * @param region  the AWS region\n     * @return the service response (query-protocol XML)\n     */\n    public Response invokeQuery(String service, MultivaluedMap<String, String> params, String region) {","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/apigateway/AwsServiceRouter.java#L157-L193","documentation":"InternalError (HTTP 500) is the catch-all rethrown by ApiGatewayService's AWS integration router when a routed service handler throws anything that is not itself an AwsException. The original exception's message is preserved when present ('e.getMessage()' is non-null), otherwise the generic text 'Service invocation failed' is used. It signals a defect or unexpected condition inside the emulator's service dispatch, not a malformed client request.","triggerScenarios":"An integration request is routed to a supported handler (sqs, sns, dynamodb, ...) and that handler throws a RuntimeException — e.g. a JSON parse error on the VTL-rendered body, a ClassCastException on a response field, or an NPE on a missing parameter the handler did not validate. The switch in invokeJson() succeeds; the failure happens inside handle().","commonSituations":"VTL request templates that render malformed JSON for the target service action, causing downstream parse exceptions. Emulator edge cases such as a target resource deleted concurrently between route and handle. Version mismatches after upgrading Floci where a handler signature changed.","solutions":["Inspect the Floci server logs for the stack trace of the wrapped exception — the InternalError message is just the original exception's getMessage(), which is often the real clue.","Capture the rendered integration request (enable API Gateway execution logging / test-invoke) and replay the same action directly against the target service to isolate whether the payload is the problem.","Simplify the VTL template to a minimal known-good body and re-add transformations incrementally until the failure reappears.","If the payload is valid, report the exception message plus the service/action pair as a Floci bug."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (AwsException e) {\n    if (\"InternalError\".equals(e.getCode())) {\n        // emulator-side fault: capture the message (it carries the cause's text) and report,\n        // never retry blindly — the same template will fail identically\n        log.error(\"Integration dispatch failed: {}\", e.getMessage());\n        throw new IntegrationExecutionException(\"Check Floci logs for the wrapped stack trace\", e);\n    }\n    throw e;\n}","preventionTips":["Test VTL templates against the target service directly before wiring them into an integration.","Run Floci with debug logging during integration development so wrapped causes are visible immediately.","Report reproducible InternalErrors with the service/action pair and template to the Floci tracker."],"tags":["apigateway","integration","internal-error","debugging"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}