{"record":{"id":"2bc8636167154cba","repo":"sherlock-project/sherlock","slug":"invalid-timeout-value-value-timeout-must-be-a","errorCode":null,"errorMessage":"Invalid timeout value: {value}. Timeout must be a positive number.","messagePattern":"Invalid timeout value: (.+?)\\. Timeout must be a positive number\\.","errorType":"validation","errorClass":"ArgumentTypeError","httpStatus":null,"severity":"error","filePath":"sherlock_project/sherlock.py","lineNumber":526,"sourceCode":"def timeout_check(value):\n    \"\"\"Check Timeout Argument.\n\n    Checks timeout for validity.\n\n    Keyword Arguments:\n    value                  -- Time in seconds to wait before timing out request.\n\n    Return Value:\n    Floating point number representing the time (in seconds) that should be\n    used for the timeout.\n\n    NOTE:  Will raise an exception if the timeout in invalid.\n    \"\"\"\n\n    float_value = float(value)\n\n    if float_value <= 0:\n        raise ArgumentTypeError(\n            f\"Invalid timeout value: {value}. Timeout must be a positive number.\"\n        )\n\n    return float_value\n\n\ndef handler(signal_received, frame):\n    \"\"\"Exit gracefully without throwing errors\n\n    Source: https://www.devdungeon.com/content/python-catch-sigint-ctrl-c\n    \"\"\"\n    sys.exit(0)\n\n\ndef main():\n    parser = ArgumentParser(\n        formatter_class=RawDescriptionHelpFormatter,\n        description=f\"{__longname__} (Version {__version__})\",","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/sherlock-project/sherlock/blob/9100f9d40a3274bd46f4ce903c5c6fee6f3745bc/sherlock_project/sherlock.py#L508-L544","documentation":"timeout_check() is the validator for the --timeout CLI option (and any programmatic timeout value passed through argparse). It converts the input with float(value) and rejects anything that is not strictly greater than zero by raising argparse's ArgumentTypeError. In CLI context argparse turns this into a usage message and exit code 2; called as a function it propagates as an exception.","triggerScenarios":"Running `sherlock --timeout 0 target` or `sherlock --timeout -5 target`; passing a timeout of 0 programmatically via the CLI parser. Note the two neighboring failure modes: a non-numeric string like \"--timeout abc\" raises ValueError from float(value) at line 523 (not this error), and this error fires only when the value parses to a number <= 0.","commonSituations":"Scripts that compute timeout from another variable which can legitimately be 0 (e.g. an unset env var defaulting to 0); users assuming 0 means 'no timeout / wait forever'; negative values from misparsed arguments or misconfigured config files feeding the CLI.","solutions":["Pass a positive number of seconds: `sherlock --timeout 10 username` (sherlock's own default when omitted is positive).","If the intent was 'wait indefinitely', drop the --timeout flag instead of setting 0 — requests requires a positive numeric timeout.","If a wrapper script computes the value, guard it: use `max(value, some_positive_default)` or substitute a default when the computed value is <= 0.","When calling timeout_check() directly in code, catch argparse.ArgumentTypeError and re-prompt or fall back to a sane default."],"exampleFix":"# before\nsherlock --timeout 0 john_doe\n\n# after\nsherlock --timeout 10 john_doe","handlingStrategy":"validation","validationCode":"from sherlock_project.sherlock import timeout_check\n\nCLITimeout = float  # positive seconds\n\ndef safe_timeout(raw) -> float:\n    try:\n        return timeout_check(raw)\n    except ValueError:  # non-numeric\n        return 10.0  # sherlock-style default\n    except Exception:  # ArgumentTypeError for <= 0\n        return 10.0","typeGuard":"def is_positive_timeout(value) -> bool:\n    if isinstance(value, bool):\n        return False\n    if isinstance(value, (int, float)):\n        return value > 0\n    try:\n        return float(value) > 0\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Never pass 0 or negative timeouts; there is no 'infinite' value — omit the option to use the default.","In wrapper scripts, clamp computed timeouts: timeout = max(computed, 1).","Remember argparse handles this for CLI use (usage error, exit 2); manual handling is only needed when importing timeout_check().","Distinguish the two failures: non-numeric input raises ValueError from float(); numeric-but-nonpositive raises ArgumentTypeError."],"tags":["sherlock","cli","argparse","timeout","validation"],"backgroundTag":null,"analyzedSha":"9100f9d40a3274bd46f4ce903c5c6fee6f3745bc","analyzedAt":"2026-08-14T19:48:26.535Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}