You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Andrea Cosentino (Jira)" <ji...@apache.org> on 2026/10/15 11:49:00 UTC

[jira] [Work started] (CAMEL-25663) camel-rest-openapi - mock mode throws NullPointerException for an operation without a 200 response when no mock file matches

     [ https://issues.apache.org/jira/browse/CAMEL-25663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on CAMEL-25663 started by Andrea Cosentino.
------------------------------------------------
> camel-rest-openapi - mock mode throws NullPointerException for an operation without a 200 response when no mock file matches
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25663
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25663
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-rest-openapi
>            Reporter: Federico Mariani
>            Assignee: Andrea Cosentino
>            Priority: Major
>
> In mock mode ({{missingOperation=mock}}), {{DefaultRestOpenapiProcessorStrategy.loadMockData}} (components/camel-rest-openapi, main 4.23.0-SNAPSHOT, around line 333) falls back to the example of the {{200}} response when no mock file matches the request:
> {code:java}
> if (operation.getResponses() != null) {
>     ApiResponse a = operation.getResponses().get("200");
>     Content c = a.getContent();
> {code}
> {{a}} is null for an operation whose responses do not include {{200}} (for example only {{201}}, {{204}}, {{default}} or {{2XX}}), so the request fails with a {{NullPointerException}} instead of the documented "returns an empty body with 204" behaviour. Reproduced in-process while writing the test of the camel-jbang-mcp scaffold (CAMEL-25642 section C): a GET operation of the petstore spec with only a {{default}} response, no mock file, {{missingOperation=mock}}.
> Fix: treat a missing {{200}} (and a {{200}} without content) like "no example": answer 204 with an empty body, or fall back to the first {{2xx}} / {{default}} response that has content.
> _Claude Code on behalf of Croway_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)