Skip to content

Improve download error failures#36

Open
ehennestad wants to merge 2 commits intomainfrom
codex-improve-error-when-download-fails
Open

Improve download error failures#36
ehennestad wants to merge 2 commits intomainfrom
codex-improve-error-when-download-fails

Conversation

@ehennestad
Copy link
Copy Markdown
Contributor

What changed

  • improve error handling when versions.json and related metadata downloads fail
  • raise a clear DownloadError instead of falling through to a later FileNotFoundError
  • make SSL certificate verification failures report a clearer, more actionable message
  • add versions.json to .gitignore so the downloaded file is not tracked accidentally

Why

When the validator could not download versions.json, it logged a network error and then continued into a confusing FileNotFoundError because the file was never created.

Impact

Validation failures caused by download problems should now be easier to understand and diagnose, especially for local SSL certificate issues.

Validation

  • parsed openMINDS_validation/utils.py successfully with ast.parse
  • did not run the full validator flow

Comment on lines +24 to +25
class DownloadError(RuntimeError):
pass
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could improve this by adding an init method that accepts url and path as part of the exception, instead of passing and handling them separately throughout the code.

Comment on lines +58 to +63
def _format_download_error(url, path, error):
if isinstance(error, urllib.error.URLError) and isinstance(error.reason, ssl.SSLCertVerificationError):
reason = "SSL certificate verification failed. Check your local Python certificate store."
else:
reason = str(error)
return f'Failed to download "{url}" to "{path}": {reason}'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move "_format_download_error" into DownloadError as a @classmethod, and rename it to something like from_exception, since its responsibility is focused only on producing a clear error message.

@Raphael-Gazzotti Raphael-Gazzotti added the enhancement New feature or request label May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants