[ 
https://issues.apache.org/jira/browse/CAMEL-24349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18106732#comment-18106732
 ] 

Andrea Cosentino commented on CAMEL-24349:
------------------------------------------

Fixed on main via https://github.com/apache/camel/pull/25563 (4.22.0). Main 
only: the change hardens createFunction argument validation to fail with a 
clear message instead of an opaque NPE - an error-handling improvement rather 
than a critical defect, so not backported.

> camel-google-functions: createFunction fails with an opaque NPE when required 
> headers are missing
> -------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24349
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24349
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-google-functions
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 4.22.0
>
>
> {{createFunction}} passes header values straight into protobuf setters:
> {code:java}
> // GoogleCloudFunctionsProducer.java:185-193
> final String entryPoint = 
> exchange.getIn().getHeader(GoogleCloudFunctionsConstants.ENTRY_POINT, 
> String.class);
> final String runtime = 
> exchange.getIn().getHeader(GoogleCloudFunctionsConstants.RUNTIME, 
> String.class);
> final String sourceArchiveUrl = 
> exchange.getIn().getHeader(GoogleCloudFunctionsConstants.SOURCE_ARCHIVE_URL, 
> String.class);
> CloudFunction function = CloudFunction.newBuilder()
>         .setName(...).setEntryPoint(entryPoint)
>         
> .setRuntime(runtime).setHttpsTrigger(HttpsTrigger.getDefaultInstance())
>         .setSourceArchiveUrl(sourceArchiveUrl).build();
> {code}
> Protobuf setters reject null, so a missing header produces a bare NPE instead 
> of a message naming the header that is required.
> Also {{listFunctions}} (:96-101) sets {{setPageSize(Integer.MAX_VALUE)}} 
> while already iterating with {{iterateAll()}}, which handles pagination 
> itself - the explicit page size should be dropped or set to a value the API 
> accepts.
> Found during a source audit of the {{components/camel-google}} module family 
> against main @ c3b01310be15.



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

Reply via email to