qmnonic opened a new issue #6809:
URL: https://github.com/apache/pulsar/issues/6809


   **Describe the bug**
   Seems there was a change in the 
https://pulsar.apache.org/admin/v3/functions/{tenant}/{namespace}/{functionName}
 function, where the method signature changed, specifically the functionConfig 
parameter, which switched from a String (in 2.4.0) to an object (2.5.1) in 
FunctionsApiV3Resource.java as shown below in 2.5.1:
   
    ```
      @POST
       @Path("/{tenant}/{namespace}/{functionName}")
       @Consumes(MediaType.MULTIPART_FORM_DATA)
       public void registerFunction(final @PathParam("tenant") String tenant,
                                    final @PathParam("namespace") String 
namespace,
                                    final @PathParam("functionName") String 
functionName,
                                    final @FormDataParam("data") InputStream 
uploadedInputStream,
                                    final @FormDataParam("data") 
FormDataContentDisposition fileDetail,
                                    final @FormDataParam("url") String 
functionPkgUrl,
                                    final @FormDataParam("functionConfig") 
FunctionConfig functionConfig) {
   ```
   
   POSTs that worked before now return `400, Bad Request, b'{"reason":"Function 
config is not provided"}'`
   The result of this is it's seemingly impossible to register a function via 
the REST API (from python).  Perhaps I'm missing something?
   
   **To Reproduce**
   Steps to reproduce the behavior:
   2 different approaches, neither seem to work?  Both return 
   
   ```
       api_url = f"{API_URL_BASE}/v3/functions/{tenant}/{namespace}/{name}"
       files = {
           'url': 
'file://pulsar/lib/org.apache.pulsar-pulsar-functions-api-examples-2.5.1.jar',
           'functionConfig': json.dumps({ 'tenant': 'example'})
        response = requests.post(api_url, files=files)
   ```
   
   error: 400, Bad Request, b'{"reason":"Function config is not provided"}'
   
   ```
   mp_encoder = MultipartEncoder(
           fields={
               'url': 
'file://pulsar/lib/org.apache.pulsar-pulsar-functions-api-examples-2.5.1.jar',
               'functionConfig': json.dumps({ 'tenant': 'example'}),
           }
       )
       headers = {'Content-Type': mp_encoder.content_type}
        response = requests.post(api_url, data=mp_encoder, headers=headers)
   ```
   
   error: 400, Bad Request, b'{"reason":"Function config is not provided"}' 
   
   
   **Expected behavior**
   Expect an HTTP 200 and to see the function register.
   
   **Desktop (please complete the following information):**
    - OS: osx posting to linux running pulsar within the pulsar-all docker 
container
   
   **Additional context**
   Add any other context about the problem here.
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to