Skip to content

Code Snippets: Check if API Response is None #1554

@sentry

Description

@sentry

Sentry Issue: BOT-Z7

When _fetch_response catches an exception, it returns None. The code that uses the response does not check if it's None, leading to the error below. I think it's only used in _snippet_to_codeblock, so a None check in there should suffice.

AttributeError: 'NoneType' object has no attribute 'splitlines'
  File "discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "bot/exts/info/code_snippets.py", line 231, in on_message
    snippet = await handler(**match.groupdict())
  File "bot/exts/info/code_snippets.py", line 92, in _fetch_github_snippet
    return self._snippet_to_codeblock(file_contents, file_path, start_line, end_line)
  File "bot/exts/info/code_snippets.py", line 180, in _snippet_to_codeblock
    split_file_contents = file_contents.splitlines()

Unhandled exception in on_message.

Metadata

Metadata

Assignees

Labels

a: informationRelated to information commands: (doc, help, information, reddit, site, tags)good first issueGood for newcomersl: 0 - beginnerp: 3 - lowLow Priorityt: bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions