davsclaus opened a new pull request, #29733: URL: https://github.com/apache/camel/pull/29733
_Claude Code on behalf of Claus Ibsen_ ## Problem [CAMEL-26280](https://issues.apache.org/jira/browse/CAMEL-26280): the `invokeFunction` operation of camel-azure-functions builds its URL with `String.format("https://%s.azurewebsites.net/api/%s", functionApp, functionName)`. Neither value, from the endpoint or from the `CamelAzureFunctionsFunctionApp` / `CamelAzureFunctionsFunctionName` headers, is checked: - a missing function app is not detected and becomes `https://null.azurewebsites.net/...`, which only fails later with a confusing connection error; - a function app that is not an Azure app name (with a dot, slash, colon, at sign, ...) is copied into the URL as is, so the URL no longer has the documented form; - a function name with a query, a fragment or `.` / `..` segments is copied into the path as is, and characters such as a space are not encoded. ## Change - `FunctionsProducer.invokeFunction` fails the exchange with an `IllegalArgumentException` when the function app is missing or is not an app name (letters, digits and hyphens, not starting or ending with a hyphen, at most 60 characters), or when the function name has a `?`, `#`, `\` or `%`, an empty segment, or a `.` or `..` segment. A function name of several segments, such as `products/42` for a function with a custom route, is still accepted. - The URL is built with the multi-argument `java.net.URI` constructor, so the function name is encoded as a path, and its host is checked to be `<functionApp>.azurewebsites.net`. - `FunctionsInvocationClient` only adds the `x-functions-key` header to `https` URLs on an `azurewebsites.net` host. - `FunctionsEndpoint.getServiceUrl()` returns a URL only for a valid app name. - The component doc states the accepted forms (catalog copy regenerated), and the 4.24 upgrade guide has a short note. Valid configurations are not affected. ## Tests - New `FunctionsProducerFunctionUrlTest` (no Azure access, a stubbed invocation client records the URL): the URL is on the app host, the app of the header is used, a multi-segment route is accepted, the function name is encoded, and a missing or invalid function app and function names with a query, a fragment, dot segments or empty segments are rejected without invoking the function; `getServiceUrl` for valid and invalid apps. - `FunctionsProducerInvokeTest.functionKeyIsOnlyAddedForHttpsFunctionAppUrls`: the key header is not added for the plain http URL of the local test server. - `mvn install` in `components/camel-azure/camel-azure-functions`: 55 unit tests, 0 failures. With the production change reverted, 28 of the new tests fail on their assertions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
