{"record":{"id":"b9e12c2250c25042","repo":"floci-io/floci","slug":"invalidrequestexception","errorCode":"InvalidRequestException","errorMessage":"WorkGroup is required.","messagePattern":"WorkGroup is required\\.","errorType":"error_code","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/athena/AthenaJsonHandler.java","lineNumber":100,"sourceCode":"            case \"ListDatabases\" -> {\n                String catalog = request.has(\"CatalogName\") ? request.get(\"CatalogName\").asText() : AthenaService.DEFAULT_CATALOG;\n                yield Response.ok(Map.of(\"DatabaseList\", athenaService.listDatabases(catalog))).build();\n            }\n            case \"ListTableMetadata\" -> {\n                String catalog = request.has(\"CatalogName\") ? request.get(\"CatalogName\").asText() : AthenaService.DEFAULT_CATALOG;\n                String database = request.path(\"DatabaseName\").asText(request.path(\"Database\").asText(\"\"));\n                yield Response.ok(Map.of(\"TableMetadataList\", athenaService.listTableMetadata(catalog, database))).build();\n            }\n            case \"GetTableMetadata\" -> {\n                String catalog = request.has(\"CatalogName\") ? request.get(\"CatalogName\").asText() : AthenaService.DEFAULT_CATALOG;\n                String database = request.path(\"DatabaseName\").asText(request.path(\"Database\").asText(\"\"));\n                String tableName = request.get(\"TableName\").asText();\n                yield Response.ok(Map.of(\"TableMetadata\", athenaService.getTableMetadata(catalog, database, tableName))).build();\n            }\n            case \"DeleteWorkGroup\" -> {\n                String wg = request.path(\"WorkGroup\").asText(null);\n                if (wg == null || !wg.matches(\"[a-zA-Z0-9._-]{1,128}\")) {\n                    throw new AwsException(\"InvalidRequestException\", \"WorkGroup is required.\", 400);\n                }\n                if (\"primary\".equals(wg)) {\n                    throw new AwsException(\"InvalidRequestException\", \"The primary workgroup cannot be deleted.\", 400);\n                }\n                athenaService.deleteWorkGroup(wg, region);\n                yield Response.ok(Map.of()).build();\n            }\n            default -> throw new AwsException(\"InvalidAction\", \"Action \" + action + \" is not supported\", 400);\n        };\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":112,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/athena/AthenaJsonHandler.java#L82-L112","documentation":"Raised by the Athena emulator's DeleteWorkGroup handler when the request has no WorkGroup field or the value fails the [a-zA-Z0-9._-]{1,128} pattern. It maps to AWS Athena's InvalidRequestException with HTTP 400, matching the real service's requirement that a workgroup name be present and well-formed.","triggerScenarios":"Calling DeleteWorkGroup via the AWS SDK (athenaClient.deleteWorkGroup(r -> r.workGroup(\"\"))) or CLI (aws athena delete-work-group) without a workgroup name, with an empty string, or with illegal characters (spaces, slashes, unicode).","commonSituations":"Scripts that build the request from a variable that is null/empty (e.g. missing env var or CLI flag), or name-generation code that introduces characters Athena forbids.","solutions":["Pass a non-empty WorkGroup name: deleteWorkGroup(r -> r.workGroup(\"my-workgroup\")).","Validate the name against ^[a-zA-Z0-9._-]{1,128}$ before issuing the call.","Check the request body actually includes WorkGroup (a typo'd builder method silently omits it).","Note 'primary' is rejected separately — see the 'primary workgroup cannot be deleted' error."],"exampleFix":"// before\nathenaClient.deleteWorkGroup(r -> r.workGroup(System.getenv(\"WG\")));\n\n// after\nString wg = System.getenv(\"WG\");\nif (wg == null || !wg.matches(\"[a-zA-Z0-9._-]{1,128}\")) throw new IllegalArgumentException(\"WorkGroup required\");\nathenaClient.deleteWorkGroup(r -> r.workGroup(wg));","handlingStrategy":"validation","validationCode":"private static final Pattern WG = Pattern.compile(\"[a-zA-Z0-9._-]{1,128}\");\nstatic void requireValidWorkGroup(String name) {\n    if (name == null || !WG.matcher(name).matches())\n        throw new IllegalArgumentException(\"WorkGroup is required and must match [a-zA-Z0-9._-]{1,128}\");\n}","typeGuard":"static boolean isValidWorkGroupName(String n) {\n    return n != null && n.matches(\"[a-zA-Z0-9._-]{1,128}\");\n}","tryCatchPattern":"try {\n    athenaClient.deleteWorkGroup(r -> r.workGroup(name));\n} catch (InvalidRequestException e) {\n    if (e.getMessage().contains(\"WorkGroup is required\")) throw new IllegalArgumentException(\"name missing\", e);\n    throw e;\n}","preventionTips":["Validate the name pattern at config-load time, not call time.","Fail fast when required request fields come from env vars that may be unset.","Reserve 'primary' handling in shared validation helpers."],"tags":["athena","workgroup","validation","aws-emulator","delete"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}