{"record":{"id":"81b13911d7327bc6","repo":"quarkusio/quarkus","slug":"no-foo-allowed","errorCode":null,"errorMessage":"No foo allowed","messagePattern":"No foo allowed","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"info","filePath":"integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java","lineNumber":41,"sourceCode":"\n    @Query\n    public String message() {\n        return message;\n    }\n\n    @Query\n    public Greeting hello() {\n        return new Greeting(\"hello\", LocalTime.of(11, 34));\n    }\n\n    @Mutation\n    public Greetings load(Greetings greetings) {\n        return greetings;\n    }\n\n    @Mutation\n    public String error(@DefaultValue(\"Foo\") String name) throws BusinessException {\n        throw new BusinessException(\"No foo allowed\");\n    }\n\n    @Name(\"options\")\n    public List<Greeting> buildInOptions(@Source Greeting greeting) {\n        List<Greeting> options = new ArrayList<>();\n        options.add(new Hello());\n        return options;\n    }\n\n    @Name(\"options2\")\n    // make sure that returning Collection.class does not break native mode\n    public Collection<Greeting> buildInOptionsCollection(@Source Greeting greeting) {\n        List<Greeting> options = new ArrayList<>();\n        options.add(new Morning());\n        return options;\n    }\n\n    @Query","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java#L23-L59","documentation":"A BusinessException with message 'No foo allowed' is thrown by the @Mutation 'error' field of the GraphQL GreetingResource. It is a deliberate domain exception used to test how SmallRye GraphQL surfaces business exceptions to clients (error extensions, error classification, exception mappers). It always fires for the default name value 'Foo'.","triggerScenarios":"Executing the GraphQL mutation { error } (or error(name:\"Foo\")) — the mutation unconditionally throws BusinessException('No foo allowed').","commonSituations":"Running the smallrye-graphql integration tests, verifying @ErrorCodes/exception-mapper behavior, or manually probing the GraphQL endpoint with the error mutation.","solutions":["This is intentional test behavior — assert the GraphQL response contains the expected error with data:null instead of treating it as a failure.","If mapping behavior is under test, check the BusinessException @ErrorCode/exception-mapper registration.","For a successful mutation call, use other mutations of the resource (e.g. greetings/load) rather than 'error'.","When testing error payloads, query the errors/extensions fields of the GraphQL response."],"exampleFix":"// before (always throws)\n@Mutation\npublic String error(@DefaultValue(\"Foo\") String name) throws BusinessException {\n    throw new BusinessException(\"No foo allowed\");\n}\n// after (conditional, for manual use)\n@Mutation\npublic String error(@DefaultValue(\"Foo\") String name) throws BusinessException {\n    if (\"Foo\".equalsIgnoreCase(name)) {\n        throw new BusinessException(\"No foo allowed\");\n    }\n    return \"Hello \" + name;\n}","handlingStrategy":"try-catch","validationCode":"if (\"Foo\".equalsIgnoreCase(name)) {\n    // this mutation always fails for the default value; expect a GraphQL error response\n}","typeGuard":null,"tryCatchPattern":"try {\n    response = graphQLClient.post(mutation(\"{ error }\"));\n} catch (Exception e) {\n    // expected: response contains errors[0].message 'No foo allowed' and data.error == null\n}","preventionTips":["Assert on the GraphQL errors/extensions payload rather than HTTP status.","Register and test an exception mapper/@ErrorCode for BusinessException so error shape is stable.","Avoid calling the deliberate 'error' mutation outside of error-mapping tests.","Keep business exceptions typed (BusinessException) so clients can branch on them."],"tags":["graphql","mutation","business-exception","test-endpoint"],"backgroundTag":"graphql-business-exception","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}