Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

CIPO: `TypeError: Incoming markup is of an invalid type: None. Markup must be a string, a bytestring, or an open filehandle.`

Open Beginner friendly
#139 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in patzilla/access/cipo/drawing.py, where get_first_drawing_url parses document_index_html and the traceback shows it can be None. Trace how that value is fetched and compare the affected Canadian patent IDs in the issue. Done when those drawing API requests handle missing index HTML without raising this TypeError.

Written by the indexing model from the issue text.

Description

bug

Problem

When searching for "Edison Thomas" at OPS, then navigating to result page 22, on a few Canadian documents, we can observe exceptions in the web server log.

API

Those API calls are impacted.

/api/drawing/CA14210A
/api/drawing/CA14209A
/api/drawing/CA14191A
/api/drawing/CA14190A
/api/drawing/CA13775A
/api/drawing/CA13774A

Details

2026-10-26 17:50:15,596 INFO     [patzilla.access.cipo.drawing            ][waitress-0] CIPO: Fetching first drawing of "{"country": "CA", "number": "13774", "kind": "A", "ext": ""}"
2026-10-26 17:50:15,596 INFO     [patzilla.access.cipo.drawing            ][waitress-0] CIPO: Index url is "http://brevets-patents.ic.gc.ca/opic-cipo/cpd/eng/patent/13774/summary.html"
2026-10-26 17:50:15,848 ERROR    [waitress                                ][waitress-0] Exception while serving /api/drawing/CA13774A
Traceback (most recent call last):
  File "/path/to/patzilla/patzilla/access/drawing.py", line 24, in get_drawing_png
    payload = get_ops_image(document, page, kind, 'tiff')
  File "/path/to/patzilla/patzilla/access/epo/ops/api.py", line 664, in get_ops_image
    image_info = inquire_images(document)
  File "/path/to/site-packages/beaker/cache.py", line 598, in cached
    return cache[0].get_value(cache_key, createfunc=go)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/site-packages/beaker/cache.py", line 319, in get
    return self._get_value(key, **kw).get_value()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/path/to/site-packages/beaker/container.py", line 381, in get_value
    v = self.createfunc()
  File "/path/to/site-packages/beaker/cache.py", line 594, in go
    return func(*args, **kwargs)
  File "/path/to/patzilla/patzilla/access/epo/ops/api.py", line 542, in inquire_images
    raise error
pyramid.httpexceptions.HTTPNotFound: No image information for document=CA13774A

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/site-packages/waitress/channel.py", line 430, in service
    task.service()
    ~~~~~~~~~~~~^^
  File "/path/to/site-packages/waitress/task.py", line 167, in service
    self.execute()
    ~~~~~~~~~~~~^^
  File "/path/to/site-packages/waitress/task.py", line 435, in execute
    app_iter = self.channel.server.application(environ, start_response)
  File "/path/to/site-packages/waitress/proxy_headers.py", line 64, in translate_proxy_headers
    return app(environ, start_response)
  File "/path/to/site-packages/paste/deploy/config.py", line 306, in __call__
    return self.app(environ, start_response)
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/site-packages/pyramid/router.py", line 274, in __call__
    response = self.execution_policy(environ, self)
  File "/path/to/site-packages/pyramid/router.py", line 283, in default_execution_policy
    return request.invoke_exception_view(reraise=True)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/path/to/site-packages/pyramid/view.py", line 787, in invoke_exception_view
    reraise_(*exc_info)
    ~~~~~~~~^^^^^^^^^^^
  File "/path/to/site-packages/pyramid/_compat.py", line 178, in reraise
    raise value.with_traceback(tb)
  File "/path/to/site-packages/pyramid/router.py", line 281, in default_execution_policy
    return router.invoke_request(request)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/path/to/site-packages/pyramid/router.py", line 249, in invoke_request
    response = handle_request(request)
  File "/path/to/site-packages/pyramid/tweens.py", line 43, in excview_tween
    response = _error_handler(request, exc)
  File "/path/to/site-packages/pyramid/tweens.py", line 13, in _error_handler
    response = request.invoke_exception_view(exc_info)
  File "/path/to/site-packages/pyramid/view.py", line 774, in invoke_exception_view
    response = _call_view(
        registry,
    ...<7 lines>...
        request_iface=request_iface.combined,
    )
  File "/path/to/site-packages/pyramid/view.py", line 683, in _call_view
    response = view_callable(context, request)
  File "/path/to/site-packages/pyramid/viewderivers.py", line 401, in viewresult_to_response
    result = view(context, request)
  File "/path/to/site-packages/pyramid/tweens.py", line 41, in excview_tween
    response = handler(request)
  File "/path/to/site-packages/pyramid/router.py", line 147, in handle_request
    response = _call_view(
        registry, request, context, context_iface, view_name
    )
  File "/path/to/site-packages/pyramid/view.py", line 683, in _call_view
    response = view_callable(context, request)
  File "/path/to/site-packages/pyramid/config/views.py", line 169, in __call__
    return view(context, request)
  File "/path/to/site-packages/pyramid/config/views.py", line 188, in attr_view
    return view(context, request)
  File "/path/to/site-packages/pyramid/config/views.py", line 214, in predicate_wrapper
    return view(context, request)
  File "/path/to/site-packages/pyramid/viewderivers.py", line 436, in rendered_view
    result = view(context, request)
  File "/path/to/site-packages/pyramid/viewderivers.py", line 144, in _requestonly_view
    response = view(request)
  File "/path/to/site-packages/cornice/service.py", line 493, in wrapper
    response = view_(request)
  File "/path/to/patzilla/patzilla/navigator/services/composite.py", line 31, in drawing_handler
    png = get_drawing_png(patent, page, 'FullDocumentDrawing')
  File "/path/to/site-packages/beaker/cache.py", line 598, in cached
    return cache[0].get_value(cache_key, createfunc=go)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/site-packages/beaker/cache.py", line 319, in get
    return self._get_value(key, **kw).get_value()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/path/to/site-packages/beaker/container.py", line 381, in get_value
    v = self.createfunc()
  File "/path/to/site-packages/beaker/cache.py", line 594, in go
    return func(*args, **kwargs)
  File "/path/to/patzilla/patzilla/access/drawing.py", line 40, in get_drawing_png
    payload = get_cipo_image_cached(document_id)
  File "/path/to/site-packages/beaker/cache.py", line 598, in cached
    return cache[0].get_value(cache_key, createfunc=go)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/site-packages/beaker/cache.py", line 319, in get
    return self._get_value(key, **kw).get_value()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/path/to/site-packages/beaker/container.py", line 381, in get_value
    v = self.createfunc()
  File "/path/to/site-packages/beaker/cache.py", line 594, in go
    return func(*args, **kwargs)
  File "/path/to/patzilla/patzilla/access/drawing.py", line 72, in get_cipo_image_cached
    payload = get_cipo_image(document_id)
  File "/path/to/patzilla/patzilla/access/cipo/drawing.py", line 15, in fetch_first_drawing
    drawing_url = get_first_drawing_url(patent)
  File "/path/to/patzilla/patzilla/access/cipo/drawing.py", line 56, in get_first_drawing_url
    soup = BeautifulSoup(document_index_html)
  File "/path/to/site-packages/bs4/__init__.py", line 445, in __init__
    raise TypeError(
        f"Incoming markup is of an invalid type: {markup!r}. Markup must be a string, a bytestring, or an open filehandle."
    )
TypeError: Incoming markup is of an invalid type: None. Markup must be a string, a bytestring, or an open filehandle.
Dominant language
Python
Stars
123
Forks
31
Avg merge
1h 9m
Merged PRs (30d)
47

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ip-tools/patzilla

All issues in ip-tools/patzilla

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.