-
Notifications
You must be signed in to change notification settings - Fork 985
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
[bug] NotFoundException is internal #17344
Comments
Hi @snickl Thanks for your report.
According to the stability commitment (check https://docs.conan.io/2/introduction.html#stable)
Only documented things can be used in recipes. This wouldn't be a bug, but expected. As a hint, is it possible that you were important that exception from I am not sure what would be the use case to catch a |
Hi @memsharded, thanks for the quick reply! But I'll admit my use case is a bit off-the-wall and I'm curious about your insight anyway. There's CI pipeline A, building that big binary "semifinish" .tar.gz package and uploading it into an internal Artifactory generic type repository, and there's CI pipeline B that works on a repo a bit like Conan-Center. B turns A's semifinishes into Conan binary packages by having recipes fetch those archives back from Artifactory, packaging and uploading the results into a Conan type repo hosted on the same Artifactory instance. Now since these files are big and up- and downloads are somewhat of a slog, I want to leverage the Conan source cache. However that only works if I can supply sha256sums for those files. To (semi-)automate this, I first have pipeline A generate a checksums.txt file with sha256 of the semifinishes, which it uploads alongside the semifinishes themselves. Then when it comes time to update the "Conan-Center" repo, I start by invoking Conversely, if the checksum file is absent (not all A pipelines create it and some semifinishes are provided by third parties), the caching will simply not take, or I have to update I also saw that Artifactory supplies a http header with the sha256 sum, but asking for http HEAD request support in Conan may be a bit much, unless auto-updating |
The thing is that Conan recipes are not really a pure Python program or library, it is actually a DSL on top of Python with its own rules and logic. A As many of Conan users are not that experts in Python, Conan recipes syntax has tried as much as possible to avoid exceptions in user recipe code. In other words, I think there is not a single
Regarding what you are trying to do, I think I'd approach this the other way round, making it more imperative and decoupled. Just a very rough idea, I probably don't know enough about all the constraints, etc., so this might not be possible. But we tackle a lot of quite complex problems in our ConanCenter CI and this is kind of the approach we usually follow. |
The obvious alternative to exceptions would be to return a status code, but it seems that would also be a first.
Yes I thought about making it into a separate tool too, but the advantage of doing it from recipe context is that in my case, the source URL paths and filenames are also derived in the recipe methods, mostly from the version string passed via Question: In a Conan custom command implementation, would it be ok to call SourcesCachingDownloader.download() and catch NotFoundException, or would I have to spin up my own http requester? |
Yes, so far, things like This it the same rationale of why when a remote is not available or fail to connect, Conan will immediately stop. It will not continue to the next remote. Some users have requested this behavior in the past, but our experience is that it is better to fail, it is safer. If you have a remote defined, that remote should be there and work, and otherwise, stop everything and check. If you want to skip that remote, then you can There is an important thing that I might be missing here. |
No, I am afraid that that isn't public API either, so it cannot be used. The idea wouldn't be that the command download anything, the command would only download that |
Describe the bug
I have a use case where I've been using the
conan.tools.files.download()
function on an optional url/file, i.e. the file may not be there and that's not an error.When I wrote the recipe I noticed that
download()
throwsNotFoundException
if the source file is not found, and so I started catching that in my code to handle the absence case.Now #17126 has moved this exception to an internal namespace (and broke my code), so I take it I'm not supposed to reference it from recipes.
However as this is an exception that a public tool function can throw, I posit that this exception (and maybe others) should also be available to recipes.
I could probably catch it as a more generic type of exception, but I find being able to distinguish expecially 404 from other types of error useful.
Thanks!
How to reproduce it
No response
The text was updated successfully, but these errors were encountered: