question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: "IllegalArgumentException: Path parameter XXX value must not be null." should include url

See original GitHub issue

I was not properly setting a Path parameter and saw:

Caused by: java.lang.IllegalArgumentException: Path parameter "user_id" value must not be null.

The problem is that I have ~20 web requests all with the user_id path parameter. I have no easy way to diagnose which one I’m calling incorrectly. It would be great if that error message included the url.

I think it should be pretty easy to update Path to:

static final class Path<T> extends ParameterHandler<T> {
    @Override
    void apply(RequestBuilder builder, @Nullable T value) throws IOException {
        if (value == null) {
            throw new IllegalArgumentException(
                    "Path parameter \"" + name + "\" value must not be null in request "
                            + builder.baseUrl + builder.relativeUrl);
        }
        builder.addPathParam(name, valueConverter.convert(value), encoded);
    }
}

Probably worth updating all ParameterHandlers that throw when value is null.

For the record, calling a service method inside RxJava stream results in a stack trace that isn’t very helpful:

   io.reactivex.exceptions.OnErrorNotImplementedException: Path parameter "user_id" value must not be null.
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
        at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
        at io.reactivex.internal.observers.ConsumerSingleObserver.onError(ConsumerSingleObserver.java:47)
        at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:79)
        at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:109)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6121)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
     Caused by: java.lang.IllegalArgumentException: Path parameter "user_id" value must not be null.
        at retrofit2.ParameterHandler$Path.apply(ParameterHandler.java:96)
        at retrofit2.ServiceMethod.toRequest(ServiceMethod.java:111)
        at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:184)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:168)
        at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:41)
        at io.reactivex.Observable.subscribe(Observable.java:12025)
        at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
        at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:571)
        at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
        at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tir38commented, May 31, 2018

I’d be willing to work on this if I get a 👍

1reaction
tir38commented, Jan 23, 2019

@vitorhugods thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.IllegalArgumentException: Path must not be empty ...
I am loading image from mysql DB using Picasso into custom listview. The image is loading when the URL is passed ...
Read more >
I am trying to extract the uri path parameters. But I am getting ...
I am trying to store the extracted value in a variable. I have tried several mule expressions. 1.set-variable variableName="path" value="# [message.
Read more >
4. Retrieving Information - Java Servlet Programming, 2nd ...
This method returns the value of the named init parameter or null if it does not exist. The return value is always a...
Read more >
Java Unit Testing with JUnit and TestNG
Introduction to Unit Testing Framework. The various type of software testings include: Unit Test: Test individual component/class in isolation.
Read more >
Configuration - Spark 2.3.0 Documentation - Apache Spark
Spark properties control most application parameters and can be set by using a ... (e.g. master URL and application name), as well as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found