Repository navigation
fix: handle non-absolute URLs in ExtensionValidator - #2077
Conversation
URI.toURL() throws IllegalArgumentException when the URI is syntactically valid but not absolute (e.g. a homepage/repository/ bugs/qna value missing a scheme, such as "github.com/foo/bar"). That exception was not caught, so it propagated out of isInvalidURL() and caused a 500 Internal Server Error during publish instead of a normal metadata validation issue. Explicitly check URI#isAbsolute() before calling toURL(), and also catch IllegalArgumentException defensively. Fixes #2076
There was a problem hiding this comment.
Pull request overview
This PR fixes a publish-time 500 error in ExtensionValidator by correctly treating syntactically valid but non-absolute URIs (missing a scheme) as invalid metadata, ensuring the failure is reported as a normal validation issue rather than an unhandled exception.
Changes:
- Update URL validation to explicitly reject non-absolute URIs before calling
URI#toURL(). - Add
IllegalArgumentExceptionhandling as a defensive backstop during URL validation. - Add regression tests for non-absolute repository values (with and without
git+prefix) and modernize existing assertions to usegetFirst().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
It is worth to mention that the VSC Marketplace seems to accept such extensions, but will not display malformed or invalid urls. |

What
Fixes #2076 — publishing an extension fails with a 500 Internal Server Error:
Why
ExtensionValidator.isInvalidURLcallsnew URI(value).toURL()to validatehomepage,repository,bugsandqnametadata fields.URI#toURL()throwsIllegalArgumentExceptionwhen the URI is syntactically valid but not absolute (e.g. a value with no scheme, such as
github.com/foo/bar). That exception isn't aURISyntaxExceptionorMalformedURLException, sothe existing catch block let it propagate all the way out of the publish flow as an unhandled 500
error instead of being reported as a normal metadata validation issue.
Fix
URI#isAbsolute()explicitly before callingtoURL()and treat a non-absolute URI asinvalid.
IllegalArgumentExceptionin the existing try/catch as a defensive backstop.Testing
Added
testNonAbsoluteURLandtestNonAbsoluteURLWithGitPrefixtoExtensionValidatorTest,covering a repository value with no scheme (with and without the
git+prefix). All tests inExtensionValidatorTestpass.