fix(init): report a malformed --extension URL cleanly, not raw urllib text - #4324
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
fix(init): report a malformed --extension URL cleanly, not raw urllib text#4324Noor-ul-ain001 wants to merge 1 commit into
Noor-ul-ain001 wants to merge 1 commit into
Conversation
… text
`_install_extension_during_init` (src/specify_cli/commands/init.py) parses
an --extension URL spec with a bare `urlparse(ext_spec)`. An unterminated
or invalid bracketed IPv6 authority (e.g. "https://[not-an-ip]/x.zip")
makes urlparse itself raise ValueError — this became eager in Python 3.14
(previously lazy, raised only on `.hostname` access). Since the call was
unguarded, `specify init --extension <bad-url>` reported the raw urllib
message ("'not-an-ip' does not appear to be an IPv4 or IPv6 address")
instead of an actionable error.
Every sibling URL entry point in this codebase already guards this exact
case with a clean domain error: extensions/__init__.py, presets/__init__.py,
extensions/_commands.py, workflows/catalog.py (the github#3435/github#3484 lineage).
init.py's own `_ext_spec_is_url` classifier next to this function already
catches the same ValueError; this call site was the outlier.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FW9fAYsCBCAgdKWovtSyqt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_install_extension_during_init(src/specify_cli/commands/init.py) parses an--extensionURL spec with a bareparsed = urlparse(ext_spec).https://[not-an-ip]/x.zip) makesurlparse()itself raiseValueError— this became eager in Python 3.14 (previously lazy, raised only on.hostnameaccess). Since the call was unguarded,specify init --extension <bad-url>surfaced the raw urllib message ('not-an-ip' does not appear to be an IPv4 or IPv6 address) as the tracker's failure text instead of an actionable error.extensions/__init__.py,presets/__init__.py,extensions/_commands.py,workflows/catalog.py(the#3435/#3484lineage — each has an explicit comment about this).init.py's own_ext_spec_is_urlclassifier, defined right next to this function, already catches the sameValueError; this call site was the one outlier that didn't.try/except ValueErrorpattern as every sibling, raising a cleanValueError("Malformed extension URL: ...")that the caller already converts into a tracker error (per this function's own documented contract).Test plan
test_install_extension_during_init_reports_malformed_url_cleanlytotests/test_init_output_markup.py, calling_install_extension_during_initdirectly withhttps://[not-an-ip]/ext.zip.'not-an-ip' does not appear to be an IPv4 or IPv6 address) leaking through — and passes with it.tests/test_init_output_markup.pymodule — 9 passed, 3 skipped (pre-existing bash-requirement skips), no regressions.Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01FW9fAYsCBCAgdKWovtSyqt