Skip to content

[BUG] Null optional completion times raise TypeError in JSONResultParser #60

Description

@GreedyC

Describe the bug

JSONResultParser.parse_json_element() checks whether completion-time keys exist, but then divides their values by 3600 without checking for None. Its comment says to calculate only when the value is not None; a synthetic comp_main: null instead raises TypeError.

To Reproduce

Without making any request:

from howlongtobeatpy.JSONResultParser import JSONResultParser
p = JSONResultParser('Example', 'https://example.com', 0)
p.parse_json_element({'game_id': 1, 'game_name': 'Example', 'comp_main': None})
# TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

I loaded the parser and its entry class from the checkout for this local test, without loading the HTTP implementation. Control inputs comp_main=0 and comp_main=3600 yield 0.0 and 1.0 respectively.

Expected behavior

Treat a null optional completion time as unavailable, keeping the entry field None, while preserving zero and ordinary numeric values. Apply the same handling to the other optional time fields (comp_plus, comp_100, comp_all, invested_co, invested_mp).

HLTB API Version

Current repository source, Python 3.14.6, macOS arm64. This is a synthetic parser robustness reproduction, not a claim that I captured a current live API response containing null values.

This is separate from search discovery / bot-protection reports and the platform accessor issue. Existing issues and open PRs were checked. Happy to contribute a focused parser regression/fix if accepted. AI assistance was used; output reproduced locally.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions