devonfw / IDEasy

Tool to automate the setup and updates of a development environment for any project (Successor of devonfw-ide).
Apache License 2.0
8 stars 23 forks source link

ide update fails on first error #628

Closed hohwille closed 1 month ago

hohwille commented 1 month ago

Expected behavior

As a IDEasy, I want that ide update applies all updates so that I can continue working and even if one of the step fails this should not block other steps.

Actual behavior

IDEasy stops on the first error (IMHO also the same for ide create). This was already a problem in devonfw-ide and the reason why we invented steps (#282) what was too complex to implement in Bash. Now with Java we have all this, however we do not properly apply the nice infrastructure we have created.

As you can read in #102:

That is if we iterate over tools in 2.,3., and 4. and some tool update fails with an error, we should not abort the entire process and prevent other tools to get updated. Instead in Java we can now properly catch and collect the errors and include a report at the end of the process.

However, we do not properly test that all aspects of a story have really been implemented before closing and also never did a sprint review of that story.

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. ide update (with a tool that for some reason fails on update)
$ ide update
Updates are available for the settings repository. If you want to pull the latest changes, call ide update.
Start: Pull settings repository
Successfully updated settings repository.
Start: Copy configuration templates
Copy configuration templates
Start: Install or update software
Start: Install node
Version v18.20.4 of tool node is already installed
Install node
Start: Install mvn
Version 3.9.9 of tool mvn is already installed
Install mvn
Start: Install aws
Trying to download aws-2.17.52-windows-x64.msi from https://awscli.amazonaws.com/AWSCLIV2-2.17.52.msi
Failed to download from https://awscli.amazonaws.com/AWSCLIV2-2.17.52.msi
java.lang.IllegalStateException: Failed to download file from URL https://awscli.amazonaws.com/AWSCLIV2-2.17.52.msi to D:\projects\_ide\tmp\Downloads\aws-2.17.52-windows-x64.msi
        at com.devonfw.tools.ide.io.FileAccessImpl.download(FileAccessImpl.java:121)
        at com.devonfw.tools.ide.repo.AbstractToolRepository.download(AbstractToolRepository.java:160)
        at com.devonfw.tools.ide.repo.AbstractToolRepository.download(AbstractToolRepository.java:94)
        at com.devonfw.tools.ide.repo.AbstractToolRepository.download(AbstractToolRepository.java:64)
        at com.devonfw.tools.ide.tool.LocalToolCommandlet.installTool(LocalToolCommandlet.java:222)
        at com.devonfw.tools.ide.tool.LocalToolCommandlet.installTool(LocalToolCommandlet.java:177)
        at com.devonfw.tools.ide.tool.LocalToolCommandlet.installTool(LocalToolCommandlet.java:151)
        at com.devonfw.tools.ide.tool.LocalToolCommandlet.doInstall(LocalToolCommandlet.java:78)
        at com.devonfw.tools.ide.tool.LocalToolCommandlet.doInstall(LocalToolCommandlet.java:65)
        at com.devonfw.tools.ide.tool.ToolCommandlet.install(ToolCommandlet.java:233)
        at com.devonfw.tools.ide.commandlet.AbstractUpdateCommandlet.updateSoftware(AbstractUpdateCommandlet.java:170)
        at com.devonfw.tools.ide.commandlet.AbstractUpdateCommandlet.run(AbstractUpdateCommandlet.java:52)
        at com.devonfw.tools.ide.commandlet.UpdateCommandlet.run(UpdateCommandlet.java:29)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:856)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:765)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:89)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:52)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:29)
        at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.net.http@21.0.2/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:956)
        at java.net.http@21.0.2/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:133)
        at com.devonfw.tools.ide.io.FileAccessImpl.download(FileAccessImpl.java:103)
        ... 18 more
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.base@21.0.2/sun.security.ssl.Alert.createSSLException(Alert.java:130)
        at java.base@21.0.2/sun.security.ssl.TransportContext.fatal(TransportContext.java:378)
        at java.base@21.0.2/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
        at java.base@21.0.2/sun.security.ssl.TransportContext.fatal(TransportContext.java:316)
        at java.base@21.0.2/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1318)
        at java.base@21.0.2/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1195)
        at java.base@21.0.2/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1138)
        at java.base@21.0.2/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:393)
        at java.base@21.0.2/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:476)
        at java.base@21.0.2/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1273)
        at java.base@21.0.2/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1260)
        at java.base@21.0.2/java.security.AccessController.executePrivileged(AccessController.java:114)
        at java.base@21.0.2/java.security.AccessController.doPrivileged(AccessController.java:714)
        at java.base@21.0.2/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:1205)
        at java.base@21.0.2/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SSLFlowDelegate.lambda$executeTasks$3(SSLFlowDelegate.java:1134)
        at java.net.http@21.0.2/jdk.internal.net.http.HttpClientImpl$DelegatingExecutor.execute(HttpClientImpl.java:177)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SSLFlowDelegate.executeTasks(SSLFlowDelegate.java:1129)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SSLFlowDelegate.doHandshake(SSLFlowDelegate.java:1095)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:494)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:269)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:182)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
        at java.net.http@21.0.2/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:207)
        at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base@21.0.2/java.lang.Thread.runWith(Thread.java:1596)
        at java.base@21.0.2/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:833)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:214)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.base@21.0.2/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:388)
        at java.base@21.0.2/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:271)
        at java.base@21.0.2/sun.security.validator.Validator.validate(Validator.java:256)
        at java.base@21.0.2/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:284)
        at java.base@21.0.2/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:144)
        at java.base@21.0.2/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1296)
        ... 25 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.base@21.0.2/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:148)
        at java.base@21.0.2/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:129)
        at java.base@21.0.2/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
        at java.base@21.0.2/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:383)
        ... 30 more

Step 'Install or update software' ended with failure.
Step 'ide (update)' failed: com.devonfw.tools.ide.cli.CliException: Download of aws-2.17.52-windows-x64.msi failed after trying 1 URL(s).
 Step 'Install or update software' failed: null
  Step 'Install aws (*)' failed: com.devonfw.tools.ide.cli.CliException: Download of aws-2.17.52-windows-x64.msi failed after trying 1 URL(s).
3 step(s) failed out of 8 steps.
Download of aws-2.17.52-windows-x64.msi failed after trying 1 URL(s).

Error: IDEasy failed with exit code 1

As you can see the process failed on the first error instead of catching it, adding the error to the step and then failing at the end since the root step failed. Maybe we still have some lacking feature for that in our Step infrastructure but lets see.

Related/Dependent Issues

102

Comments/Hints:

Affected version:

hohwille commented 1 month ago

Bugfix: add try / catch here: https://github.com/devonfw/IDEasy/blob/b8cbd38e74925afcf47e38bdfa3877979b110d76/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java#L170