Unsupported named parameter type ResourcePath
karelmaxa opened this issue · 2 comments
The following error is returned when you try to view the detail of a managed object with relationships in the Admin UI. In my test I used the PostgreSQL repository with the default configuration.
WARNING: Resource exception: 500 Internal Server Error: "Failed to convert result objects for query SELECT fullobject::text FROM wrenidm.relationships obj INNER JOIN wrenidm.objecttypes objecttypes ON (obj.objecttypes_id = objecttypes.id AND objecttypes.objecttype = ?) WHERE (((json_extract_path_text(fullobject, ?) = ? AND json_extract_path_text(fullobject, ?) = ?) AND 1 = 1) OR ((json_extract_path_text(fullobject, ?) = ? AND json_extract_path_text(fullobject, ?) = ?) AND 1 = 1)) ORDER BY objectid ASC, objectid ASC LIMIT ? OFFSET ? with params: {_pageSize=50, _queryFilter=(((/firstId eq "managed/user/foo" and /firstPropertyName eq "roles") and true) or ((/secondId eq "managed/user/foo" and /secondPropertyName eq "roles") and true)), _queryExpression=null, _pagedResultsOffset=0, _queryId=null, _sortKeys=[+/_id]} message: Unsupported parameter type: org.forgerock.json.resource.ResourcePath"
org.forgerock.json.resource.InternalServerErrorException: Failed to convert result objects for query SELECT fullobject::text FROM wrenidm.relationships obj INNER JOIN wrenidm.objecttypes objecttypes ON (obj.objecttypes_id = objecttypes.id AND objecttypes.objecttype = ?) WHERE (((json_extract_path_text(fullobject, ?) = ? AND json_extract_path_text(fullobject, ?) = ?) AND 1 = 1) OR ((json_extract_path_text(fullobject, ?) = ? AND json_extract_path_text(fullobject, ?) = ?) AND 1 = 1)) ORDER BY objectid ASC, objectid ASC LIMIT ? OFFSET ? with params: {_pageSize=50, _queryFilter=(((/firstId eq "managed/user/foo" and /firstPropertyName eq "roles") and true) or ((/secondId eq "managed/user/foo" and /secondPropertyName eq "roles") and true)), _queryExpression=null, _pagedResultsOffset=0, _queryId=null, _sortKeys=[+/_id]} message: Unsupported parameter type: org.forgerock.json.resource.ResourcePath
at org.forgerock.openidm.repo.jdbc.impl.query.TableQueryHandler.query(TableQueryHandler.java:154)
at org.forgerock.openidm.repo.jdbc.impl.handler.GenericTableHandler.query(GenericTableHandler.java:558)
at org.forgerock.openidm.repo.jdbc.impl.JDBCRepoService.query(JDBCRepoService.java:677)
at org.forgerock.openidm.repo.jdbc.impl.JDBCRepoService.handleQuery(JDBCRepoService.java:587)
at org.forgerock.json.resource.Router.handleQuery(Router.java:327)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:103)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:92)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:92)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:92)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.audit.filter.AuditFilter$5.apply(AuditFilter.java:194)
at org.forgerock.openidm.audit.filter.AuditFilter$5.apply(AuditFilter.java:191)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:255)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:244)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:223)
at org.forgerock.openidm.audit.filter.AuditFilter.logAuditAccessEntry(AuditFilter.java:251)
at org.forgerock.openidm.audit.filter.AuditFilter.filterQuery(AuditFilter.java:190)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:90)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.servlet.internal.ServletConnectionFactory$4.filterQuery(ServletConnectionFactory.java:488)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.filter.PassthroughFilter.filterQuery(PassthroughFilter.java:74)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.filter.PassthroughFilter.filterQuery(PassthroughFilter.java:74)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.json.resource.FilterChain.handleQuery(FilterChain.java:254)
at org.forgerock.json.resource.InternalConnection.queryAsync(InternalConnection.java:82)
at org.forgerock.json.resource.AbstractConnectionWrapper.queryAsync(AbstractConnectionWrapper.java:193)
at org.forgerock.openidm.servlet.internal.ServletConnectionFactory$1$1.queryAsync(ServletConnectionFactory.java:375)
at org.forgerock.json.resource.AbstractConnectionWrapper.queryAsync(AbstractConnectionWrapper.java:193)
at org.forgerock.openidm.managed.CollectionRelationshipProvider.queryCollection(CollectionRelationshipProvider.java:394)
at org.forgerock.json.resource.InterfaceCollectionHandler.handleQuery(InterfaceCollectionHandler.java:62)
at org.forgerock.json.resource.Router.handleQuery(Router.java:327)
at org.forgerock.json.resource.Router.handleQuery(Router.java:327)
at org.forgerock.openidm.managed.ManagedObjectService$ManagedObjectSetRequestHandler.handleQuery(ManagedObjectService.java:197)
at org.forgerock.json.resource.Router.handleQuery(Router.java:327)
at org.forgerock.openidm.managed.ManagedObjectService.handleQuery(ManagedObjectService.java:322)
at org.forgerock.json.resource.Router.handleQuery(Router.java:327)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:103)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:92)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:92)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.filter.ScriptedFilter$7.apply(ScriptedFilter.java:165)
at org.forgerock.openidm.filter.ScriptedFilter$7.apply(ScriptedFilter.java:162)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:255)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:244)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:223)
at org.forgerock.openidm.filter.ScriptedFilter.filterRequest(ScriptedFilter.java:192)
at org.forgerock.openidm.filter.ScriptedFilter.filterQuery(ScriptedFilter.java:161)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:90)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.audit.filter.AuditFilter$5.apply(AuditFilter.java:194)
at org.forgerock.openidm.audit.filter.AuditFilter$5.apply(AuditFilter.java:191)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:255)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:244)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:223)
at org.forgerock.openidm.audit.filter.AuditFilter.logAuditAccessEntry(AuditFilter.java:251)
at org.forgerock.openidm.audit.filter.AuditFilter.filterQuery(AuditFilter.java:190)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.json.resource.Filters$ConditionalFilter.filterQuery(Filters.java:90)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.servlet.internal.ServletConnectionFactory$4.filterQuery(ServletConnectionFactory.java:488)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.filter.PassthroughFilter.filterQuery(PassthroughFilter.java:74)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.openidm.filter.PassthroughFilter.filterQuery(PassthroughFilter.java:74)
at org.forgerock.openidm.filter.MutableFilterDecorator.filterQuery(MutableFilterDecorator.java:98)
at org.forgerock.json.resource.FilterChain$Cursor.handleQuery(FilterChain.java:101)
at org.forgerock.json.resource.FilterChain.handleQuery(FilterChain.java:254)
at org.forgerock.json.resource.InternalConnection.queryAsync(InternalConnection.java:82)
at org.forgerock.json.resource.AbstractConnectionWrapper.queryAsync(AbstractConnectionWrapper.java:193)
at org.forgerock.openidm.servlet.internal.ServletConnectionFactory$1$1.queryAsync(ServletConnectionFactory.java:375)
at org.forgerock.json.resource.http.RequestRunner.visitQueryRequest(RequestRunner.java:262)
at org.forgerock.json.resource.http.RequestRunner.visitQueryRequest(RequestRunner.java:95)
at org.forgerock.json.resource.Requests$QueryRequestImpl.accept(Requests.java:448)
at org.forgerock.json.resource.http.RequestRunner.handleResult(RequestRunner.java:141)
at org.forgerock.json.resource.http.HttpAdapter$1.apply(HttpAdapter.java:725)
at org.forgerock.json.resource.http.HttpAdapter$1.apply(HttpAdapter.java:722)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:255)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:244)
at org.forgerock.json.resource.http.HttpAdapter.doRequest(HttpAdapter.java:722)
at org.forgerock.json.resource.http.HttpAdapter.doQuery(HttpAdapter.java:480)
at org.forgerock.json.resource.http.HttpAdapter.handle(HttpAdapter.java:293)
at org.forgerock.http.handler.Handlers$HandlerDescribableAsDescribableHandler.handle(Handlers.java:154)
at org.forgerock.http.filter.OptionsFilter.filter(OptionsFilter.java:77)
at org.forgerock.http.handler.Handlers$1.handle(Handlers.java:61)
at org.forgerock.http.swagger.OpenApiRequestFilter.filter(OpenApiRequestFilter.java:70)
at org.forgerock.http.handler.Handlers$1.handle(Handlers.java:61)
at org.forgerock.caf.authentication.framework.AuthenticationFramework.grantAccess(AuthenticationFramework.java:201)
at org.forgerock.caf.authentication.framework.AuthenticationFramework$2.apply(AuthenticationFramework.java:193)
at org.forgerock.caf.authentication.framework.AuthenticationFramework$2.apply(AuthenticationFramework.java:186)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:255)
at org.forgerock.util.promise.Promises$CompletedPromise.thenAsync(Promises.java:244)
at org.forgerock.caf.authentication.framework.AuthenticationFramework.validateRequest(AuthenticationFramework.java:151)
at org.forgerock.caf.authentication.framework.AuthenticationFramework.processMessage(AuthenticationFramework.java:141)
at org.forgerock.caf.authentication.framework.AuthenticationFilter.filter(AuthenticationFilter.java:92)
at org.forgerock.openidm.auth.AuthFilterWrapper.filter(AuthFilterWrapper.java:95)
at org.forgerock.http.handler.Handlers$1.handle(Handlers.java:61)
at org.forgerock.http.filter.TransactionIdInboundFilter.filter(TransactionIdInboundFilter.java:60)
at org.forgerock.http.handler.Handlers$1.handle(Handlers.java:61)
at org.forgerock.http.servlet.HttpFrameworkServlet.service(HttpFrameworkServlet.java:237)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:365)
at jdk.internal.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.forgerock.openidm.servletregistration.impl.ServletRegistrationSingleton$FilterProxy.invoke(ServletRegistrationSingleton.java:299)
at jdk.proxy12/jdk.proxy12.$Proxy47.doFilter(Unknown Source)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:257)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:220)
at jdk.internal.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.forgerock.openidm.servletregistration.impl.ServletRegistrationSingleton$FilterProxy.invoke(ServletRegistrationSingleton.java:299)
at jdk.proxy12/jdk.proxy12.$Proxy47.doFilter(Unknown Source)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:72)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.forgerock.json.resource.InternalServerErrorException: Unsupported parameter type: org.forgerock.json.resource.ResourcePath
at org.forgerock.openidm.repo.jdbc.impl.statement.NamedParameterSupport.applyStatementParameter(NamedParameterSupport.java:152)
at org.forgerock.openidm.repo.jdbc.impl.statement.NamedParameterSupport.applyStatementParams(NamedParameterSupport.java:122)
at org.forgerock.openidm.repo.jdbc.impl.query.TableQueryHandler.query(TableQueryHandler.java:143)
... 148 more
I forgot about manually constructed query filters with typed parameters when refactoring JDBC Repo. I have only tested string based query filters. This might be trivial fix to simply add toString
as a default parameter mapping. However this should be checked with the original code as well.
UPDATE: I can confirm that the previous implementation did convert every parameter to string (unless the parameter token contained type prefix) - https://github.com/WrenSecurity/wrenidm/blob/6.1.x/openidm-repo-jdbc/src/main/java/org/forgerock/openidm/repo/jdbc/impl/query/TableQueries.java#L524C29-L524C38
This has been solved by the linked PR.