Open imarban opened 1 day ago
@imarban what's your bazel version?
Sorry, I forgot to add: 7.3.1
May I ask you if you have any specifc flags in bazelrc? We are aware of the problem, but can't really reproduce it.
The issue linked seems to be about bazel info
and not bazel mod
. I am not entirely sure they are the same.
With regards to bazel flags, I have tried disabling all of them one by one to see if I got a different error from the plugin to no avail.
Also, worth mentioning that if I run the command printed by the plugin in the Bazel -> Sync Tool Window on my own, then it succeeds.
Interesting, sorry for this obvious recommendation, but can you please double-check if you set the right bazel
excecutable in settings?
I dug more and found another piece of stack trace that is relevant:
2024-09-26 21:19:58,299 [ 411179] WARN - #com.google.idea.blaze.base.model.ExternalWorkspaceDataProvider - Unable to run blaze mod dump_repo_mapping
java.util.concurrent.ExecutionException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 3 column 2 path $
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:594)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:573)
at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
at com.google.idea.blaze.base.model.ExternalWorkspaceDataProvider.getCachedExternalWorkspaceData(ExternalWorkspaceDataProvider.java:119)
at com.google.idea.blaze.base.model.ExternalWorkspaceDataProvider.lambda$getExternalWorkspaceData$0(ExternalWorkspaceDataProvider.java:87)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:249)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:30)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:227)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:212)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 3 column 2 path $
at com.google.gson.JsonParser.parseReader(JsonParser.java:76)
at com.google.gson.JsonParser.parseString(JsonParser.java:51)
at com.google.idea.blaze.base.command.mod.BlazeModRunnerImpl.lambda$dumpRepoMapping$3(BlazeModRunnerImpl.java:70)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:253)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:243)
at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:124)
... 13 more
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 3 column 2 path $
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1659)
at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1465)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:551)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:433)
at com.google.gson.JsonParser.parseReader(JsonParser.java:71)
... 18 more
2024-09-26 21:19:58,299 [ 411179] SEVERE - #com.google.idea.blaze.base.async.FutureUtil - com.google.idea.blaze.base.command.mod.BlazeModException: Unable to get module mapping
java.util.concurrent.ExecutionException: com.google.idea.blaze.base.command.mod.BlazeModException: Unable to get module mapping
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:594)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:573)
at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
at com.google.idea.blaze.base.async.FutureUtil$Builder.lambda$run$0(FutureUtil.java:109)
at com.google.idea.blaze.base.scope.Scope.push(Scope.java:40)
at com.google.idea.blaze.base.async.FutureUtil$Builder.run(FutureUtil.java:99)
at com.google.idea.blaze.base.sync.ProjectStateSyncTask.getExternalWorkspaceData(ProjectStateSyncTask.java:253)
at com.google.idea.blaze.base.sync.ProjectStateSyncTask.getProjectState(ProjectStateSyncTask.java:164)
at com.google.idea.blaze.base.sync.ProjectStateSyncTask.collectProjectState(ProjectStateSyncTask.java:75)
at com.google.idea.blaze.base.sync.BlazeSyncManager.lambda$requestProjectSync$1(BlazeSyncManager.java:139)
at com.google.idea.blaze.base.scope.Scope.push(Scope.java:57)
at com.google.idea.blaze.base.scope.Scope.root(Scope.java:33)
at com.google.idea.blaze.base.sync.BlazeSyncManager.lambda$requestProjectSync$2(BlazeSyncManager.java:116)
at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTask$0(ProgressiveTaskWithProgressIndicator.java:83)
at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTaskWithResult$4(ProgressiveTaskWithProgressIndicator.java:131)
at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:98)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:49)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:98)
at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTaskWithResult$5(ProgressiveTaskWithProgressIndicator.java:131)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:249)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:30)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:227)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:212)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: com.google.idea.blaze.base.command.mod.BlazeModException: Unable to get module mapping
at com.google.idea.blaze.base.model.ExternalWorkspaceDataProvider.lambda$getExternalWorkspaceData$0(ExternalWorkspaceDataProvider.java:89)
... 16 more
It seems there is an issue reading the output of bazel mod
as it's not proper JSON.
I'm trying to understand if I can influence the output of bazel mod
to be JSON but I think the plugin should fall back to the previous behavior where this was not enabled if a crash is detected.
As a workaround, please double-press shift, find Registry there and disable bazel.read.external.workspace.data. We'll fix the issue next week
cc @mtoader any ideas why this could happen?
nvm, that might be a generic issue in the process spawner, maybe we don't wait until whole output is printed
Great! The feature flag works perfectly :). I can confirm, this is happening because we augment the info printed by Bazel, hence it can't be parsed as JSON by the plugin. It's an edge case for the plugin to consider, though.
How is the info augmented? The scraper there requires the proper json output from the command though.
As a meta issue. bazel mod
failures should not break the whole sync. I'll see how I can add that.
We append a string that helps with debugging (IMO we shouldn't do it, and can look into removing it). But yeah, a failure from bazel mod
or parsing the output shouldn't break the whole sync process.
@imarban so I don't think we can correctly handle that. We can have better recovery ofc. I would recommend you to push the augmented data to stderr, or skip it for this case. Without that you won't be able to use external label completions - one of our greatest features developed recently by @mtoader :)
I'm adding silent failures now but the parsing is a different story.
@imarban For background:
bazel mod dump_repo_mapping
incantation@rules_go/<caret>
refers to and trying to complete at the caret there for example.So augmentation is probably a no-no in this case.
@mtoader no hurry, we have a workaround
Yeah, not much the plugin can do if the output does not adhere to the output format that you would get from standard bazel. I can fix that for our setup.
Thanks for working on silent failures :) - I think printing a WARN message indicating that external repositories completion won't be available would be ideal.
@tpasternak PR is up
Problem
The plugin fails during Incremental Syncs with "Error:Could not run Bazel mod dump_repo_mapping". Upon inspecting the logs, this seems to be the relevant stack trace:
Expected
The plugin syncs successfully by handling the error better and/or fixing the underlying issue.
Which category does this issue belong to?
PyCharm
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Unsure if this is specific to my repository setup but just going from 2024.08.27.0.1 to 2024.09.10.0.1 breaks it for me.
Which Intellij IDE are you using? Please provide the specific version.
PyCharm 2024.2.3
What programming languages and tools are you using? Please provide specific versions.
Python: 3.9, Bazel: 7.3.1
What Bazel plugin version are you using?
2024.09.10.0.1
Have you found anything relevant by searching the web?
Issue #6664 for which a few commits have merged seems to be in play here.
Any other information, logs, or outputs that you want to share?
No response