Skip to content

[Bug / Refactor] Silent Result.taken() fallthrough on malformed 200 responses across multiple modules #449

Description

@A-S-Manoj

Description

Several user_scan validators silently swallow parse failures on a 200 response and fall through to an unconditional Result.taken(), instead of returning Result.error(...) as required by the module guidelines:

Strict Error Handling: NEVER use raise Exception(). All unhandled states or unexpected status codes must return Result.error(f"Unexpected status code {resp.status_code}").
— CONTRIBUTING.md

When response.json() fails, or the parsed body doesn't have the expected keys, these modules report the username as taken rather than surfacing the failure — which can produce false positives whenever the API returns a malformed, rate-limited, or otherwise unexpected 200 body.

This is the same bug class fixed in cropty.py via #436 — this issue tracks the same pattern found elsewhere in the codebase.

Affected Files

File Pattern
user_scanner/user_scan/finance/destream.py except Exception: pass → falls through to return Result.taken()
user_scanner/user_scan/gaming/apexlegends.py same
user_scanner/user_scan/gaming/minecraft.py same
user_scanner/user_scan/gaming/lichess.py same
user_scanner/user_scan/gaming/chess_com.py same
user_scanner/user_scan/dev/codecademy.py except Exception: return Result.taken() directly (any exception at all is reported as "taken")
user_scanner/user_scan/dev/githubgist.py same as codecademy

Example (destream.py)

def process(response):
    if response.status_code == 200:
        try:
            data = response.json()
            ...
            return Result.taken(extra=extra)
        except Exception:
            pass
        return Result.taken()   # ← silent fallthrough, should be Result.error(...)

    if response.status_code == 404:
        return Result.available()

    return Result.error(f"Unexpected status: {response.status_code}")

Proposed Fix

Replace the bare fallback return Result.taken() (and the except Exception: return Result.taken() variant) in each file with an explicit Result.error(...), e.g.:

except Exception:
    pass
return Result.error("Unexpected 200 response shape (no recognizable data)")

I'm happy to open a PR for this myself. Could I get assigned?

Metadata

Metadata

Assignees

Labels

bug fixFixed a bug in existing files

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions