quarkusio/quarkus · info · BusinessException
No foo allowed
Error message
No foo allowed
What it means
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'.
Source
Thrown at integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java:41
@Query
public String message() {
return message;
}
@Query
public Greeting hello() {
return new Greeting("hello", LocalTime.of(11, 34));
}
@Mutation
public Greetings load(Greetings greetings) {
return greetings;
}
@Mutation
public String error(@DefaultValue("Foo") String name) throws BusinessException {
throw new BusinessException("No foo allowed");
}
@Name("options")
public List<Greeting> buildInOptions(@Source Greeting greeting) {
List<Greeting> options = new ArrayList<>();
options.add(new Hello());
return options;
}
@Name("options2")
// make sure that returning Collection.class does not break native mode
public Collection<Greeting> buildInOptionsCollection(@Source Greeting greeting) {
List<Greeting> options = new ArrayList<>();
options.add(new Morning());
return options;
}
@QueryView on GitHub (pinned to e1c734241f)
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.
Example fix
// before (always throws)
@Mutation
public String error(@DefaultValue("Foo") String name) throws BusinessException {
throw new BusinessException("No foo allowed");
}
// after (conditional, for manual use)
@Mutation
public String error(@DefaultValue("Foo") String name) throws BusinessException {
if ("Foo".equalsIgnoreCase(name)) {
throw new BusinessException("No foo allowed");
}
return "Hello " + name;
} Defensive patterns
Strategy: try-catch
Validate before calling
if ("Foo".equalsIgnoreCase(name)) {
// this mutation always fails for the default value; expect a GraphQL error response
} Try / catch
try {
response = graphQLClient.post(mutation("{ error }"));
} catch (Exception e) {
// expected: response contains errors[0].message 'No foo allowed' and data.error == null
} Prevention
- 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.
When it happens
Trigger: Executing the GraphQL mutation { error } (or error(name:"Foo")) — the mutation unconditionally throws BusinessException('No foo allowed').
Common situations: Running the smallrye-graphql integration tests, verifying @ErrorCodes/exception-mapper behavior, or manually probing the GraphQL endpoint with the error mutation.
Related errors
- The '%s' annotation has been used to configure the '%s' OIDC
- GraphQL client with config key '%s' wasn't present in the co
- graphql/graphql-client.js not found on classpath
- graphql/graphql-client.d.ts not found on classpath
- Unknown websocket subprotocol:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/81b13911d7327bc6.
Report an issue: GitHub.