{"record":{"id":"303353a56db70ee0","repo":"floci-io/floci","slug":"badrequestexception-303353","errorCode":"BadRequestException","errorMessage":"Invalid resource ARN: {arn}","messagePattern":"Invalid resource ARN: (.+?)","errorType":"validation","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigTagHandler.java","lineNumber":77,"sourceCode":"    }\n\n    @Override\n    public void untagResource(String region, String arn, List<String> tagKeys) {\n        ResourceRef ref = parseArn(arn);\n        if (\"application\".equals(ref.type())) {\n            service.untagApplication(ref.id(), tagKeys);\n        }\n    }\n\n    private record ResourceRef(String type, String id) {}\n\n    private static ResourceRef parseArn(String arn) {\n        // arn:aws:appconfig:<region>:<account>:<resource>\n        String resource;\n        try {\n            resource = AwsArnUtils.parse(arn).resource();\n        } catch (IllegalArgumentException e) {\n            throw new AwsException(\"BadRequestException\", \"Invalid resource ARN: \" + arn, 400);\n        }\n        String[] parts = resource.split(\"/\");\n        if (parts.length >= 2 && \"application\".equals(parts[0])) {\n            // application/<appId>\n            if (parts.length == 2) return new ResourceRef(\"application\", parts[1]);\n            // application/<appId>/environment/<envId>\n            // application/<appId>/configurationprofile/<profileId>\n            if (parts.length == 4) return new ResourceRef(parts[2], parts[3]);\n            // application/<appId>/environment/<envId>/deployment/<num>\n            if (parts.length == 6) return new ResourceRef(parts[4], parts[5]);\n        }\n        throw new AwsException(\"BadRequestException\", \"Invalid resource ARN: \" + arn, 400);\n    }\n}\n","sourceCodeStart":59,"sourceCodeEnd":92,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigTagHandler.java#L59-L92","documentation":"Thrown by AppConfig's standalone tag handler (TagResource/UntagResource/ListTagsForResource) when the supplied ResourceArn cannot be parsed as an ARN at all — AwsArnUtils.parse() raises IllegalArgumentException and the handler converts it to BadRequestException (HTTP 400) with 'Invalid resource ARN: <arn>'. This is the structural failure; error 155 is the shape failure after a successful parse.","triggerScenarios":"Passing a bare resource id ('abc1234'), an AppConfig application name, or a malformed string ('appconfig:us-east-1:application/abc') as ResourceArn. Also passing values with fewer or more than the six colon-separated ARN components.","commonSituations":"Confusing the application's Name with its Id and ARN. Hand-assembling ARNs from region + id and dropping a field. Passing the deployment number or environment name alone because that is what the console displays.","solutions":["Use a full AppConfig ARN: arn:aws:appconfig:<region>:<account>:application/<appId>.","For nested resources keep the whole path: application/<appId>/environment/<envId>, application/<appId>/configurationprofile/<profileId>, or .../environment/<envId>/deployment/<n>.","Copy the ARN from the create response (CreateApplication returns an ARN) rather than building it.","Add a caller-side preflight regex: ^arn:aws:appconfig:[a-z0-9-]+:\\d{12}:application(/.*)?$."],"exampleFix":"# before\naws appconfig tag-resource --resource-arn my-app-name --tags k=v\n\n# after\naws appconfig tag-resource \\\n  --resource-arn arn:aws:appconfig:us-east-1:123456789012:application/abc1234 \\\n  --tags k=v","handlingStrategy":"validation","validationCode":"// Structural check before tagging\nif (resourceArn == null || !resourceArn.startsWith(\"arn:aws:appconfig:\")) {\n    throw new IllegalArgumentException(\n        \"Expected arn:aws:appconfig:<region>:<account>:application/..., got: \" + resourceArn);\n}\nappConfigClient.tagResource(TagResourceRequest.builder()\n    .resourceArn(resourceArn).tags(tags).build());","typeGuard":"boolean isAppConfigArn(String s) {\n    if (s == null) return false;\n    String[] p = s.split(\":\", 6);\n    return p.length == 6 && \"arn\".equals(p[0]) && s.contains(\":application\")\n        || p.length == 6 && p[5].startsWith(\"application/\");\n}","tryCatchPattern":null,"preventionTips":["Use the ARN returned by CreateApplication/CreateEnvironment rather than hand-building it.","Never pass names or bare ids as ResourceArn.","Centralize ARN building for every service you tag."],"tags":["appconfig","arn","tagging","validation"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}