wso2 / micro-integrator

The cloud-native configuration driven runtime that helps developers implement composite microservices.
https://wso2.com/integration/
Apache License 2.0
203 stars 221 forks source link

IllegalArgumentException while consuming an API in Micro Integrator #3752

Open ajit-pendse opened 1 day ago

ajit-pendse commented 1 day ago

Description

New project is created with a simple Endpoint and API calling this endpoint, hosted on local Micro Integrator through Integration Studio.

While consuming API, client receives a HTTP 500 Error code with body as -

{
    "Fault": {
        "faultcode": "soapenv:Server",
        "faultstring": "Label cannot be null.",
        "detail": null
    }
}

In the server console, following stacktrace is printed -

ERROR {ServerWorker} - Error processing POST request for : /listing/create. java.lang.IllegalArgumentException: Label cannot be null.
    at io.prometheus.client.SimpleCollector.labels(SimpleCollector.java:68)
    at org.wso2.micro.integrator.observability.metric.handler.prometheus.reporter.PrometheusReporter.incrementCount(PrometheusReporter.java:204)
    at org.wso2.micro.integrator.observability.metric.handler.MetricHandler.incrementApiErrorCount(MetricHandler.java:290)
    at org.wso2.micro.integrator.observability.metric.handler.MetricHandler.handleError(MetricHandler.java:171)
    at org.apache.synapse.FaultHandler.executeExtendedSynapseHandlerOnFault(FaultHandler.java:166)
    at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:80)
    at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:107)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:401)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:460)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:208)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)

Steps to Reproduce

  1. Open Integration Studio
  2. Create a new project containing docker exporter and kubernetes exporter (apart from composite exporters and Configs projects)
  3. Create a new Endpoint pointing to any external backend
  4. Create an API calling this endpoint and exposing a route
  5. Call the exposed route of API from a client like Postman

Version

4.3.0

Environment Details (with versions)

OS - Mac OS Sequoia 15.1 Integration Studio - 8.3.0 Java/JRE - openjdk version "17.0.13" 2024-10-15 OpenJDK Runtime Environment Homebrew (build 17.0.13+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.13+0, mixed mode, sharing)

ajit-pendse commented 1 day ago

I could find a workaround and the underlying issue. This occurs mainly due to implementation in this method - org.wso2.micro.integrator.observability.metric.handler.MetricHandler#getApiName. This method only checks for non-Null version - however, version-type set to none in the API actually returns an empty string for version. This leads to the apiContextPath being appended with a `/'. This fails the equality test later in the method and is unable to find the correct API.

Updating version-type="url" and version="1" in the API definition and invoking API with URI ending with /1 made this work.

To make non-versioned APIs will mostly need a fix to check for empty string as well.

SanojPunchihewa commented 1 day ago

@ajit-pendse This issue is already fixed via https://github.com/wso2/micro-integrator/pull/3627. It is also available as an U2 update for MI 4.3.0

ajit-pendse commented 1 day ago

Great! Thanks for the quick response.

corrosive4354 commented 22 hours ago

Hello, I see you are using homebrew, but actually homebrew is not very friendly to Mac, you can try Servbay, which is more professional than homebrew on Mac