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

Querying transferprocess with certain state not possible #3319

Closed
tuncaytunc-zf opened this issue Jul 20, 2023 · 7 comments · Fixed by #3320
Closed

Querying transferprocess with certain state not possible #3319

tuncaytunc-zf opened this issue Jul 20, 2023 · 7 comments · Fixed by #3320
Labels
bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification

Comments

@tuncaytunc-zf
Copy link
Contributor

Bug Report

Describe the Bug

Queriying all transfer process in certain state by using 'filterExpression' is not possible.

Expected Behavior

It should be possible to query all transferprocesses with certain sate.

Observed Behavior

If you try to query all transferprocess in certain by using 'filterExpression' fails with a HTTP 500 error.

Steps to Reproduce

Steps to reproduce the behavior:
Use following json to query all transferprocesses with status COMPLETED

{
    "@context": {
        "edc": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "@type": "QuerySpec",
    "filterExpression": [
        {
            "operandLeft": "state",
            "operandRight": "COMPLETED",
            "operator": "="
        }
    ],
    "limit": 100,
    "offset": 0
}

Context Information

  • Used version [e.g. EDC v0.1.3]

Detailed Description

Error message from Controlplane::

Caused by: org.postgresql.util.PSQLException: FEHLER: Operator does not exist: integer = character varying
  Hint: No operator matches the specified name and argument types. You may need to add explicit casts.
  Position: 188
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
    at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:134)
    at org.eclipse.edc.sql.SqlQueryExecutor.query(SqlQueryExecutor.java:93)

The field state in database is defined as int but the API is using string and produces a SQL query with ...WHERE state = 'COMPLETED' which fails because the database expects a int value for state.

Possible Implementation

The API should convert the string states into corresponding int values when querying the database.

@tuncaytunc-zf tuncaytunc-zf added bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification labels Jul 20, 2023
@paullatzelsperger
Copy link
Member

paullatzelsperger commented Jul 20, 2023

this is not a bug. the state is an enum in Java code and is therefor persisted as INTEGER. the stated expression does exactly what the exception states: comparing an INTEGER with "COMPLETED", which is a VARCHAR.

Sticking with the example, the correct expression would be:

"filterExpression": [
        {
            "operandLeft": "state",
            "operandRight": 800,
            "operator": "="
        }
    ],

Just tried this our successfully in a test. Can you try again with that?

Please check out the codes in TransferProcessStates

@tuncaytunc-zf
Copy link
Contributor Author

If I use the suggested request, I'm getting a error message "message": "Value must be OBJECT or ARRAY but was: NUMBER"
The API allows only String but the state is stored as int. So how to query it.

@paullatzelsperger
Copy link
Member

can you post the stacktrace?

@tuncaytunc-zf
Copy link
Contributor Author

Unfortunately it is partially in German thefore I didn't post the whole stacktrace :-)

2023-07-20 13:50:52 SEVERE 2023-07-20T11:50:52.849400945 JerseyExtension: Unexpected exception caught
2023-07-20 13:50:52 org.eclipse.edc.spi.persistence.EdcPersistenceException: org.postgresql.util.PSQLException: FEHLER: Operator existiert nicht: integer = character varying
2023-07-20 13:50:52   Hint: Kein Operator stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.
2023-07-20 13:50:52   Position: 188
2023-07-20 13:50:52     at org.eclipse.edc.sql.SqlQueryExecutor.query(SqlQueryExecutor.java:104)
2023-07-20 13:50:52     at org.eclipse.edc.connector.store.sql.transferprocess.store.SqlTransferProcessStore.executeQuery(SqlTransferProcessStore.java:190)
2023-07-20 13:50:52     at org.eclipse.edc.connector.store.sql.transferprocess.store.SqlTransferProcessStore.lambda$findAll$6(SqlTransferProcessStore.java:160)
2023-07-20 13:50:52     at org.eclipse.edc.transaction.local.LocalTransactionContext.execute(LocalTransactionContext.java:74)
2023-07-20 13:50:52     at org.eclipse.edc.connector.store.sql.transferprocess.store.SqlTransferProcessStore.findAll(SqlTransferProcessStore.java:158)
2023-07-20 13:50:52     at org.eclipse.edc.connector.service.transferprocess.TransferProcessServiceImpl.lambda$query$1(TransferProcessServiceImpl.java:83)
2023-07-20 13:50:52     at org.eclipse.edc.transaction.local.LocalTransactionContext.execute(LocalTransactionContext.java:74)
2023-07-20 13:50:52     at org.eclipse.edc.connector.service.transferprocess.TransferProcessServiceImpl.query(TransferProcessServiceImpl.java:83)
2023-07-20 13:50:52     at org.eclipse.edc.connector.api.management.transferprocess.TransferProcessApiController.queryTransferProcesses(TransferProcessApiController.java:88)
2023-07-20 13:50:52     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-07-20 13:50:52     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2023-07-20 13:50:52     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2023-07-20 13:50:52     at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
2023-07-20 13:50:52     at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
2023-07-20 13:50:52     at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
2023-07-20 13:50:52     at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
2023-07-20 13:50:52     at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
2023-07-20 13:50:52     at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
2023-07-20 13:50:52     at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
2023-07-20 13:50:52     at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
2023-07-20 13:50:52     at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
2023-07-20 13:50:52     at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:240)
2023-07-20 13:50:52     at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
2023-07-20 13:50:52     at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
2023-07-20 13:50:52     at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
2023-07-20 13:50:52     at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
2023-07-20 13:50:52     at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
2023-07-20 13:50:52     at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
2023-07-20 13:50:52     at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
2023-07-20 13:50:52     at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:529)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
2023-07-20 13:50:52     at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:192)
2023-07-20 13:50:52     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
2023-07-20 13:50:52     at org.eclipse.jetty.server.Server.handle(Server.java:563)
2023-07-20 13:50:52     at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
2023-07-20 13:50:52     at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
2023-07-20 13:50:52     at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
2023-07-20 13:50:52     at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
2023-07-20 13:50:52     at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
2023-07-20 13:50:52     at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
2023-07-20 13:50:52     at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:416)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:385)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:272)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:140)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
2023-07-20 13:50:52     at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
2023-07-20 13:50:52     at java.base/java.lang.Thread.run(Unknown Source)
2023-07-20 13:50:52 Caused by: org.postgresql.util.PSQLException: FEHLER: Operator existiert nicht: integer = character varying
2023-07-20 13:50:52   Hint: Kein Operator stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.
2023-07-20 13:50:52   Position: 188
2023-07-20 13:50:52     at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
2023-07-20 13:50:52     at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401)
2023-07-20 13:50:52     at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
2023-07-20 13:50:52     at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
2023-07-20 13:50:52     at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
2023-07-20 13:50:52     at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
2023-07-20 13:50:52     at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:134)
2023-07-20 13:50:52     at org.eclipse.edc.sql.SqlQueryExecutor.query(SqlQueryExecutor.java:93)
2023-07-20 13:50:52     ... 62 more

@paullatzelsperger
Copy link
Member

paullatzelsperger commented Jul 20, 2023

No i meant to ask if there is a stacktrace with the Value must be OBJECT.... message

@tuncaytunc-zf
Copy link
Contributor Author

For that I don't get a single line of logs, even I'm running it in debug log level :-)

@paullatzelsperger
Copy link
Member

paullatzelsperger commented Jul 20, 2023

I think I found the culprit:

//JsonObjectToCriterionTransformer.java#l48

builder.operandRight(transformString(operandRight, context));

Technically there are two ways to solve this:

  1. store everything as VARCHAR in the DB
  2. make the JsonObjectToCriterionTransformer transform numbers correctly. Inferring the correct type (int, double,...) could be tricky though.

The latter seems to be the better approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification
Projects
None yet
2 participants