{"record":{"id":"1adb15563bca35d7","repo":"donnemartin/interactive-coding-challenges","slug":"num-cannot-be-none","errorCode":null,"errorMessage":"num cannot be None","messagePattern":"num cannot be None","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"arrays_strings/fizz_buzz/fizz_buzz_solution.ipynb","lineNumber":115,"sourceCode":"  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Code\"\n   ]\n  },\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": 1,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": [\n    \"class Solution(object):\\n\",\n    \"\\n\",\n    \"    def fizz_buzz(self, num):\\n\",\n    \"        if num is None:\\n\",\n    \"            raise TypeError('num cannot be None')\\n\",\n    \"        if num < 1:\\n\",\n    \"            raise ValueError('num cannot be less than one')\\n\",\n    \"        results = []\\n\",\n    \"        for i in range(1, num + 1):\\n\",\n    \"            if i % 3 == 0 and i % 5 == 0:\\n\",\n    \"                results.append('FizzBuzz')\\n\",\n    \"            elif i % 3 == 0:\\n\",\n    \"                results.append('Fizz')\\n\",\n    \"            elif i % 5 == 0:\\n\",\n    \"                results.append('Buzz')\\n\",\n    \"            else:\\n\",\n    \"                results.append(str(i))\\n\",\n    \"        return results\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/donnemartin/interactive-coding-challenges/blob/358f2cc60426d5c4c3d7d580910eec9a7b393fa9/arrays_strings/fizz_buzz/fizz_buzz_solution.ipynb#L97-L133","documentation":"Raised by Solution.fizz_buzz when num is None. The method iterates range(1, num+1), so None would fail comparison; the guard rejects it up front with a clear TypeError. num must be a positive integer.","triggerScenarios":"Calling fizz_buzz(None); passing an unset counter or a value parsed from unvalidated input.","commonSituations":"CLI/script arguments not converted to int; API handlers forwarding optional query params directly.","solutions":["Validate and convert input to int before calling (e.g. int(request.args['n']))","Default None to a sensible value like 0 or 1 depending on desired behavior","Use argument parsing that enforces a required integer"],"exampleFix":"# before\nSolution().fizz_buzz(params.get('n'))\n\n# after\nn = int(params['n'])\nSolution().fizz_buzz(n)","handlingStrategy":"validation","validationCode":"if num is not None:\n    Solution().fizz_buzz(num)","typeGuard":"def is_positive_int(num) -> bool:\n    return isinstance(num, int) and num >= 1","tryCatchPattern":"try:\n    Solution().fizz_buzz(num)\nexcept TypeError:\n    num = 1  # or return an error to the caller","preventionTips":["Convert and validate numeric input at the boundary","Use argparse/validators that require an int"],"tags":["fizz-buzz","input-validation","typeerror","none-check"],"backgroundTag":"none-argument-rejected","analyzedSha":"358f2cc60426d5c4c3d7d580910eec9a7b393fa9","analyzedAt":"2026-08-28T10:16:54.480Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}