Closed ohgo closed 3 years ago
Hi @ohgo
Could you try to pass SCOPES environment variables: -e SOURCE_SCOPES=manage_products
or e TARGET_SCOPES=manage_products
? you might pass multiple values with comma: manage_customers,manage_products
.
Hi @ahmetoz, thanks for the tip! The app seems understand SOURCE_SCOPES and TARGET_SCOPES. And I saw the PR too, thanks for quickly fixing that. Could I suggest documenting even the minimum required scope for each resource sync (if you don't think that's obvious).
During my trial and errors, I ran into intermittent warning when syncing Products (-s products). This sounds unrelated to this scope issue, in which case we can close this anyway. But I'd like your confirmation, and perhaps a pointer on how to troubleshoot if possible.
{
"timestamp": "2021-07-01T13:08:01.857Z",
"severity": "INFO",
"loggerName": "com.commercetools.project.sync.product.ProductSyncer",
"message": "Starting ProductSync from CTP project with key 'source-project' to project with key 'target-project'"
}
Jul 01, 2021 1:08:04 PM org.javamoney.moneta.DefaultMonetaryContextFactory createMonetaryContextNonNullConfig
INFO: Using custom MathContext: precision=256, roundingMode=HALF_EVEN
{
"timestamp": "2021-07-01T13:08:05.397Z",
"severity": "WARN",
"loggerName": "com.commercetools.project.sync.product.ProductSyncer",
"message": "java.lang.IllegalArgumentException: argument \"content\" is null",
"stackHash": "1adc93c3",
"stackTrace": "j.l.IllegalArgumentException: argument \"content\" is null\n\tat c.f.j.d.ObjectReader._assertNotNull(ObjectReader.java:2366)\n\tat c.f.j.d.ObjectReader.readValue(ObjectReader.java:1665)\n\tat i.s.s.j.SphereJsonUtils.lambda$readObject$9(SphereJsonUtils.java:238)\n\tat i.s.s.j.SphereJsonUtils.executing(SphereJsonUtils.java:324)\n\tat i.s.s.j.SphereJsonUtils.readObject(SphereJsonUtils.java:238)\n\tat c.c.s.c.h.GraphQlBaseRequestImpl.deserializeWithResourceName(GraphQlBaseRequestImpl.java:77)\n\tat c.c.s.c.m.ResourceIdsGraphQlRequest.deserialize(ResourceIdsGraphQlRequest.java:27)\n\tat c.c.s.c.m.ResourceIdsGraphQlRequest.deserialize(ResourceIdsGraphQlRequest.java:14)\n\tat i.s.s.c.SphereClientImpl.parse(SphereClientImpl.java:139)\n\tat i.s.s.c.SphereClientImpl.processHttpResponse(SphereClientImpl.java:129)\n\tat i.s.s.c.SphereClientImpl.lambda$executeWithRecover$4(SphereClientImpl.java:86)\n\tat j.u.c.CompletableFuture$UniApply.tryFire(Unknown Source)\n\tat j.u.c.CompletableFuture$Completion.exec(Unknown Source)\n\tat j.u.c.ForkJoinTask.doExec(Unknown Source)\n\tat j.u.c.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)\n\tat j.u.c.ForkJoinPool.scan(Unknown Source)\n\tat j.u.c.ForkJoinPool.runWorker(Unknown Source)\n\tat j.u.c.ForkJoinWorkerThread.run(Unknown Source)\n"
}
{
"timestamp": "2021-07-01T13:08:05.465Z",
"severity": "INFO",
"loggerName": "com.commercetools.project.sync.product.ProductSyncer",
"message": "Summary: 0 product(s) were processed in total (0 created, 0 updated, 0 failed to sync and 0 product(s) with missing reference(s)).",
"statistics": {
"updated": 0,
"created": 0,
"failed": 0,
"processed": 0,
"latestBatchProcessingTimeInDays": 0,
"latestBatchProcessingTimeInHours": 0,
"latestBatchProcessingTimeInMinutes": 0,
"latestBatchProcessingTimeInSeconds": 0,
"latestBatchProcessingTimeInMillis": 1,
"latestBatchHumanReadableProcessingTime": "0d, 0h, 0m, 0s, 1ms",
"reportMessage": "Summary: 0 product(s) were processed in total (0 created, 0 updated, 0 failed to sync and 0 product(s) with missing reference(s)).",
"numberOfProductsWithMissingParents": 0
}
}
Could I suggest documenting even the minimum required scope for each resource sync (if you don't think that's obvious).
I would like to document that but it depends on the what are you trying to do with app as it might have many combinations, so scope of each combination might be different. So I would suggest to check https://docs.commercetools.com/api/scopes page and try to find minimum scope needed for your case.
For the case that you have shared, I have not seen this issue before, the stack trace also does not say much, it looks like the issue happened on parsing the graphql response it might be the query requires more scope, as this normally not happens. The result also interesting as the nothings seems like failed 🤔
I would like to document that but it depends on the what are you trying to do with app as it might have many combinations,
You're right. I think it's not that hard to figure out anyway.
Yeah, I'll see if I can nail down what is causing this intermittent warning later. Feel free to close this issue whenever you feel appropriate. Thanks again for the help!
@ohgo did you manage to find a solution for this? Having similar issues
@ritammv I've hit this problem a couple of days ago, and it was because of not enough scope in my API client. So try giving your client a bigger scope.
Hi @heshamMassoud thanks for heads up :) The confusion might be here due to custom objects which have quite extensive permission requirements.
@butenkor From the stacktrace posted above (and also similar to the one I got), seems something related to the GraphQL requests no? :)
j.l.IllegalArgumentException: argument \"content\" is null\n\tat c.f.j.d.ObjectReader._assertNotNull(ObjectReader.java:2366)\n\tat c.f.j.d.ObjectReader.readValue(ObjectReader.java:1665)\n\tat i.s.s.j.SphereJsonUtils.lambda$readObject$9(SphereJsonUtils.java:238)\n\tat i.s.s.j.SphereJsonUtils.executing(SphereJsonUtils.java:324)\n\tat i.s.s.j.SphereJsonUtils.readObject(SphereJsonUtils.java:238)\n\tat c.c.s.c.h.GraphQlBaseRequestImpl.deserializeWithResourceName(GraphQlBaseRequestImpl.java:77)\n\tat c.c.s.c.m.ResourceIdsGraphQlRequest.deserialize(ResourceIdsGraphQlRequest.java:27)\n\tat c.c.s.c.m.ResourceIdsGraphQlRequest.deserialize(ResourceIdsGraphQlRequest.java:14)\n\tat i.s.s.c.SphereClientImpl.parse(SphereClientImpl.java:139)\n\tat i.s.s.c.SphereClientImpl.processHttpResponse(SphereClientImpl.java:129)\n\tat i.s.s.c.SphereClientImpl.lambda$executeWithRecover$4(SphereClientImpl.java:86)\n\tat j.u.c.CompletableFuture$UniApply.tryFire(Unknown Source)\n\tat j.u.c.CompletableFuture$Completion.exec(Unknown Source)\n\tat j.u.c.ForkJoinTask.doExec(Unknown Source)\n\tat j.u.c.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)\n\tat j.u.c.ForkJoinPool.scan(Unknown Source)\n\tat j.u.c.ForkJoinPool.runWorker(Unknown Source)\n\tat j.u.c.ForkJoinWorkerThread.run(Unknown Source)\n
I had the same error as original poster and by increasing the scope it worked for me! if syncing custom objects you need the view_customers scope on the source (hope that helps)
On Fri, 23 Jun 2023 at 13:07, Hesham Massoud @.***> wrote:
@butenkor https://github.com/butenkor From the stacktrace posted above (and also similar to the one I got), seems something related to the GraphQL requests no? :)
j.l.IllegalArgumentException: argument \"content\" is null\n\tat c.f.j.d.ObjectReader._assertNotNull(ObjectReader.java:2366)\n\tat c.f.j.d.ObjectReader.readValue(ObjectReader.java:1665)\n\tat i.s.s.j.SphereJsonUtils.lambda$readObject$9(SphereJsonUtils.java:238)\n\tat i.s.s.j.SphereJsonUtils.executing(SphereJsonUtils.java:324)\n\tat i.s.s.j.SphereJsonUtils.readObject(SphereJsonUtils.java:238)\n\tat c.c.s.c.h.GraphQlBaseRequestImpl.deserializeWithResourceName(GraphQlBaseRequestImpl.java:77)\n\tat c.c.s.c.m.ResourceIdsGraphQlRequest.deserialize(ResourceIdsGraphQlRequest.java:27)\n\tat c.c.s.c.m.ResourceIdsGraphQlRequest.deserialize(ResourceIdsGraphQlRequest.java:14)\n\tat i.s.s.c.SphereClientImpl.parse(SphereClientImpl.java:139)\n\tat i.s.s.c.SphereClientImpl.processHttpResponse(SphereClientImpl.java:129)\n\tat i.s.s.c.SphereClientImpl.lambda$executeWithRecover$4(SphereClientImpl.java:86)\n\tat j.u.c.CompletableFuture$UniApply.tryFire(Unknown Source)\n\tat j.u.c.CompletableFuture$Completion.exec(Unknown Source)\n\tat j.u.c.ForkJoinTask.doExec(Unknown Source)\n\tat j.u.c.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)\n\tat j.u.c.ForkJoinPool.scan(Unknown Source)\n\tat j.u.c.ForkJoinPool.runWorker(Unknown Source)\n\tat j.u.c.ForkJoinWorkerThread.run(Unknown Source)\n
— Reply to this email directly, view it on GitHub https://github.com/commercetools/commercetools-project-sync/issues/304#issuecomment-1604189758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP4KV5ZTK3IQWMEUD5ZQGHTXMWBHFANCNFSM47SLYQ3A . You are receiving this because you were mentioned.Message ID: @.*** com>
Hi,
The sync seems to need _manageproject scope to run. Surely it should be able to run even using api credentials with lower privilege? For instance when syncing Products, it should be enough with view:products on the source project and manage:products on the destination project. So that we don't create api clients with unnecessarily permissive privileges.
To reproduce:
The error: