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

HTTP 500 on /v2/edrs/request with sortField #1380

Closed
arnoweiss opened this issue Jun 26, 2024 · 6 comments
Closed

HTTP 500 on /v2/edrs/request with sortField #1380

arnoweiss opened this issue Jun 26, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@arnoweiss
Copy link
Contributor

Describe the bug

When trying to sort for the createdAt property of an EDR, the Consumer Control Plane returns HTTP 500.

To Reproduce

  1. Provider: Create passable contract definition
  2. Consumer: Negotiate, trigger transfer into EDR cache. Twice.
  3. Execute POST /v2/edrs/request with body:
{
  "@context": {
    "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
  },
  "@type": "QuerySpec",
  "offset": 0,
  "limit": 10,
  "sortOrder": "DESC",
  "sortField": "createdAt",
  "filterExpression": [
    {
      "operandLeft": "assetId",
      "operator": "=",
      "operandRight": "27832ff3-11d7-45c9-9b95-fbaadd43db8a"
    },
    {
      "operandLeft": "providerId",
      "operator": "=",
      "operandRight": "BPNL00000007RF54"
    }
  ]
}
  1. Behold HTTP 500 response
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
		<title>Error 500 Internal Server Error</title>
	</head>
	<body>
		<h2>HTTP ERROR 500 Internal Server Error</h2>
		<table>
			<tr>
				<th>URI:</th>
				<td>/management/v2/edrs/request</td>
			</tr>
			<tr>
				<th>STATUS:</th>
				<td>500</td>
			</tr>
			<tr>
				<th>MESSAGE:</th>
				<td>Internal Server Error</td>
			</tr>
			<tr>
				<th>SERVLET:</th>
				<td>EDC-management</td>
			</tr>
		</table>
	</body>
</html>

Expected behavior

HTTP 200 with the relevant EDRs sorted by creation timestamp.
Similar scenarios:

  • /v2/edrs/request:
    • Sorting for agreementId works.
    • Sorting for https://w3id.org/edc/v0.0.1/ns/createdAt crashes with HTTP 500.
  • /v2/policydefinitions/request
    • Sorting for createdAt works.
    • Sorting for @id crashes with HTTP 500.

Screenshots/Error Messages

Control Plane Logs

SEVERE 2024-06-26T07:46:01.422176612 JerseyExtension: Unexpected exception caught
org.eclipse.edc.spi.EdcException: Cannot sort by createdAt because the field does not exist
    at org.eclipse.edc.transaction.local.LocalTransactionContext.execute(LocalTransactionContext.java:81)
    at org.eclipse.edc.edr.store.index.SqlEndpointDataReferenceEntryIndex.query(SqlEndpointDataReferenceEntryIndex.java:63)
    at org.eclipse.edc.edr.store.EndpointDataReferenceStoreImpl.lambda$query$2(EndpointDataReferenceStoreImpl.java:58)
    at org.eclipse.edc.transaction.local.LocalTransactionContext.execute(LocalTransactionContext.java:74)
    at org.eclipse.edc.edr.store.EndpointDataReferenceStoreImpl.query(EndpointDataReferenceStoreImpl.java:58)
    at org.eclipse.tractusx.edc.api.edr.v2.EdrCacheApiController.requestEdrEntries(EdrCacheApiController.java:130)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:146)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:189)
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:93)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:266)
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:242)
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:358)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:312)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:529)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:192)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
    at org.eclipse.jetty.server.Server.handle(Server.java:563)
    at org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
    at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)
    at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:199)
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Cannot sort by createdAt because the field does not exist
    at org.eclipse.edc.sql.translation.SqlQueryStatement.parseSortField(SqlQueryStatement.java:171)
    at org.eclipse.edc.sql.translation.SqlQueryStatement.initialize(SqlQueryStatement.java:161)
    at org.eclipse.edc.sql.translation.SqlQueryStatement.<init>(SqlQueryStatement.java:74)
    at org.eclipse.edc.sql.translation.SqlQueryStatement.<init>(SqlQueryStatement.java:58)
    at org.eclipse.edc.edr.store.index.sql.schema.BaseSqlDialectStatements.createQuery(BaseSqlDialectStatements.java:78)
    at org.eclipse.edc.edr.store.index.SqlEndpointDataReferenceEntryIndex.lambda$query$1(SqlEndpointDataReferenceEntryIndex.java:66)
    at org.eclipse.edc.transaction.local.LocalTransactionContext.execute(LocalTransactionContext.java:74)
    ... 57 more

Context Information

  • Used version: tractusx-edc 0.7.2
  • official chart

Possible Implementation

This may be an upstream issue. The relevant class (EndpointDataReferenceEntry) indeed has no createdAt field. Other payloads (such as IdResponse) have it. Yet, the createdAt property is correctly returned if the sortField and sortProperty are not set in the QuerySpec request.

@arnoweiss arnoweiss added bug Something isn't working triage all new issues awaiting classification labels Jun 26, 2024
@wolf4ood
Copy link
Contributor

Hi @arnoweiss

i would not consider this a bug, this is a feature request of sorting by createdAt property. It could be that
the sorting option is not available on that field in upstream EDC. I would consider this as enhancement and raise the
request in upstream EDC

@wolf4ood wolf4ood added enhancement New feature or request and removed bug Something isn't working triage all new issues awaiting classification labels Jun 26, 2024
@wolf4ood
Copy link
Contributor

Raised also on upstream EDC

@arnoweiss
Copy link
Contributor Author

Thanks! What feels buggy is that the case isn't handled (leading to HTTP 500) and the inconsistency between /v2/edrs/request and /v2/policydefinitions/request. That's why I'd leave it open and see if the feature upstream fixes that behavior.

@wolf4ood
Copy link
Contributor

Yeah, i understand that feels buggy, but imho it's a missing feature (sorting by a field) instead of a wrong behavior :)

@wolf4ood
Copy link
Contributor

wolf4ood commented Jul 8, 2024

Hi @arnoweiss

it has been implemented in upstream EDC in this PR

eclipse-edc/Connector#4337

I guess it will be available in the next TX-EDC release

@wolf4ood
Copy link
Contributor

Hey @arnoweiss

closing this. The upstream eclipse-edc/Connector#4337 has been included in upstream 0.8.0 and therefore in the tractusx-edc 0.8.0-rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants