bkkothari2255 commented on PR #24: URL: https://github.com/apache/sling-org-apache-sling-feature-extension-apiregions/pull/24#issuecomment-6090319324
> That does not really help, as this PR starts too high in the stack; at that point it's unclear if there as a network issue (timeout), and authentication problem or if the artifact does not exist. But we need these details for diagnosis, and I think this information as part of an exception message is already good enough. > > For that `org.apache.sling.feature.io.artifacts.ArtifactManager.getArtifactHandler` (where the current exception is thrown) also too high in the stack, as `ArtifactManager.getArtifact()` can only return a URL (or null), but neither throw an exception or an otherwise structured response (record/object) to better describe the problem. > > That means, we would need to change the interface of the `ArtifactProvider` and introduce a new method `@NotNull URL getArtifact2(final String url, Stirng relativeCachePath) throws IOException`(better names welcome), which will never return null, but in case of problems throw an `IOException`. Hi @joerghoh, Thanks for the guidance, That makes total sense I have implemented your suggested approach in `sling-org-apache-sling-feature` - Added `default URL getArtifactFile(String url, String relativeCachePath) throws IOException` to `ArtifactProvider` (bumped SPI package to `1.1.0`) - Updated `DefaultArtifactHandler` so it captures the actual HTTP response code (401/403/404) and connection timeouts instead of swallowing them - Updated `ArtifactManager.getArtifactHandler()` to collect per-repository failures and include them in the exception the resulting `IOException`. Tested locally with `feature-launcher` against a missing bundle, and it now produces this exact diagnostic output ```text [ERROR] Error during bootstrap java.lang.IllegalStateException: Error while assembling launcher with repositories [https://repo1.maven.org/maven2]: Artifact 'org.apache.sling:non-existent-diagnostic-bundle:9.9.9' not found in repositories: [https://repo1.maven.org/maven2] ... Caused by: java.io.IOException: Artifact :org/apache/sling/non-existent-diagnostic-bundle/9.9.9/non-existent-diagnostic-bundle-9.9.9.jar not found in configured repositories: - https://repo1.maven.org/maven2: HTTP 404 Not Found from https://repo1.maven.org/maven2/org/apache/sling/non-existent-diagnostic-bundle/9.9.9/non-existent-diagnostic-bundle-9.9.9.jar at org.apache.sling.feature.io.artifacts.ArtifactManager.getArtifactHandler(ArtifactManager.java:334) ... Suppressed: java.io.IOException: HTTP 404 Not Found from https://repo1.maven.org/maven2/org/apache/sling/non-existent-diagnostic-bundle/9.9.9/non-existent-diagnostic-bundle-9.9.9.jar at org.apache.sling.feature.io.artifacts.ArtifactManager$DefaultArtifactHandler.getArtifactFile(ArtifactManager.java:510) ... Caused by: java.io.FileNotFoundException: https://repo1.maven.org/maven2/org/apache/sling/non-existent-diagnostic-bundle/9.9.9/non-existent-diagnostic-bundle-9.9.9.jar -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
