Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException while consuming an API in Micro Integrator #3752

Open
ajit-pendse opened this issue Oct 30, 2024 · 4 comments
Open
Labels

Comments

@ajit-pendse
Copy link

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
Copy link
Author

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
Copy link
Contributor

@ajit-pendse This issue is already fixed via #3627. It is also available as an U2 update for MI 4.3.0

@ajit-pendse
Copy link
Author

Great! Thanks for the quick response.

@corrosive4354
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants