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

better/more informative error than "Not a REST client interface: interface update$PlaylistService" #19556

Closed
maxandersen opened this issue Aug 21, 2021 · 8 comments · Fixed by #19572
Labels
Milestone

Comments

@maxandersen
Copy link
Member

Description

Given:

@RegisterRestClient(baseUri = "https://www.googleapis.com/youtube/v3/playlistItems")
    public static interface PlaylistService {

        @GET
        List<String> playlist(@QueryParam("part") String part,
                          @QueryParam("maxResults") int maxResults,
                          @QueryParam("playlistId") String playListId,
                          @QueryParam("key") String key);
    }

in a class I get:

021-08-21 02:26:44,151 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.IllegalArgumentException: Not a REST client interface: interface update$PlaylistService
	at org.jboss.resteasy.reactive.client.impl.ClientProxies.get(ClientProxies.java:26)
	at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.proxy(WebTargetImpl.java:382)
	at io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl.build(RestClientBuilderImpl.java:273)
	at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.build(RestClientCDIDelegateBuilder.java:76)
	at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.createDelegate(RestClientCDIDelegateBuilder.java:57)
	at io.quarkus.rest.client.reactive.runtime.RestClientReactiveCDIWrapperBase.<init>(RestClientReactiveCDIWrapperBase.java:16)
	at update$PlaylistService$$CDIWrapper.<init>(update$PlaylistService$$CDIWrapper.zig:21)
	at update$PlaylistService$$CDIWrapper_ClientProxy.<init>(update$PlaylistService$$CDIWrapper_ClientProxy.zig:24)
	at update$PlaylistService$$CDIWrapper_Bean.proxy(update$PlaylistService$$CDIWrapper_Bean.zig:40)
	at update$PlaylistService$$CDIWrapper_Bean.get(update$PlaylistService$$CDIWrapper_Bean.zig:243)
	at update$PlaylistService$$CDIWrapper_Bean.get(update$PlaylistService$$CDIWrapper_Bean.zig:259)
	at update_Bean.create(update_Bean.zig:210)
	at update_Bean.create(update_Bean.zig:293)
	at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
	at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
	at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
	at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
	at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:17)
	at update_ClientProxy.arc$delegate(update_ClientProxy.zig:67)
	at update_ClientProxy.run(update_ClientProxy.zig:126)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:123)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:30)

despite all the types and annotations matches what is in resteasy reactive client docs.

Could this error message be a bit more explicit on what makes this not a REST client interface?

Implementation ideas

No response

@maxandersen maxandersen added the kind/enhancement New feature or request label Aug 21, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 21, 2021

/cc @michalszynkiewicz

@maxandersen
Copy link
Member Author

in this case it seem to be that @javax.ws.rs.Path("/youtube/v3/playlistItems") was missing.

@gastaldi
Copy link
Contributor

gastaldi commented Aug 21, 2021

Yeah the error message could be more descriptive, like interface update$PlaylistService is not a valid REST Client interface because the @javax.ws.rs.Path annotation is missing

@stuartwdouglas
Copy link
Member

Should we really required the path? If it is missing but @RegisterRestClient is present we should just default it to '/' IMHO.

@michalszynkiewicz
Copy link
Member

michalszynkiewicz commented Aug 23, 2021

The interface @maxandersen posted should work.
This should pick it up:

// for clients it is also enough to only have @GET, @POST, etc on methods and no PATH whatsoever
Set<DotName> methodAnnotations = httpAnnotationToMethod.keySet();
for (DotName methodAnnotation : methodAnnotations) {
for (AnnotationInstance methodAnnotationInstance : index.getAnnotations(methodAnnotation)) {
if (methodAnnotationInstance.target().kind() == AnnotationTarget.Kind.METHOD) {
MethodInfo annotatedMethod = methodAnnotationInstance.target().asMethod();
ClassInfo classWithJaxrsMethod = annotatedMethod.declaringClass();
if (Modifier.isAbstract(annotatedMethod.flags())
&& Modifier.isAbstract(classWithJaxrsMethod.flags())
&& !clientInterfaces.containsKey(classWithJaxrsMethod.name())) {
clientInterfaces.put(classWithJaxrsMethod.name(), "");
}
}
}
}

What we currently do is we find all the interfaces that have @Path either on the class level or on the method level, or have any annotation like @POST, etc, on any of the methods.

I'll try to reproduce the problem.

@maxandersen
Copy link
Member Author

Could it be one of the dreaded "code assumes every class is in a package" kinda thing ?

@stuartwdouglas
Copy link
Member

It happens when you have no @path, but you do have an @RegisterRestClient .

@michalszynkiewicz
Copy link
Member

#19572 should fix this

michalszynkiewicz added a commit to michalszynkiewicz/quarkus that referenced this issue Aug 23, 2021
@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Aug 23, 2021
@gsmet gsmet modified the milestones: 2.3 - main, 2.2.0.Final Aug 23, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants