Skip to content

Line number not provided on build failure when urllib urlsplit fails #3939

@alexandra-lambda

Description

@alexandra-lambda

It's unfortunate for usability that in a case like this a line number (in the markdown file being processed) isn't provided. In my case this was a http://host URL which was missing the trailing / but the failure to propagate line number information made it hard to diagnose except by a naive process of elimination. I began to look at the code, but I'm not yet sure if this is possible to do without modifications to the markdown library, so I am not submitting a PR at this time. Thanks

DEBUG   -  [macros] - Rendering source page: path/to/file.md
DEBUG   -  [macros] - Page title: Some Title
DEBUG   -  Running `page_markdown` event from plugin 'table-reader'
ERROR   -  Error reading page 'path/to/file.md': Invalid IPv6 URL
Traceback (most recent call last):
  File "/Users/alexandra.magin/code/engineering-docs/.venv/bin/mkdocs", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/mkdocs/__main__.py", line 288, in build_command
    build.build(cfg, dirty=not clean)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/mkdocs/commands/build.py", line 310, in build
    _populate_page(file.page, config, files, dirty)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
    page.render(config, files)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/mkdocs/structure/pages.py", line 285, in render
    self.content = md.convert(self.markdown)
                   ~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/markdown/core.py", line 361, in convert
    newRoot = treeprocessor.run(root)
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/mkdocs/structure/pages.py", line 370, in run
    new_url = self.path_to_url(url)
  File "/Users/alexandra.magin/code/engineering-docs/.venv/lib/python3.13/site-packages/mkdocs/structure/pages.py", line 420, in path_to_url
    scheme, netloc, path, query, anchor = urlsplit(url)
                                          ~~~~~~~~^^^^^
  File "/Users/alexandra.magin/.local/share/uv/python/cpython-3.13.2-macos-aarch64-none/lib/python3.13/urllib/parse.py", line 514, in urlsplit
    raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions