{"record":{"id":"89885e083debbd8f","repo":"langchain-ai/deepagents","slug":"list-must-be-positive","errorCode":null,"errorMessage":"--list must be positive","messagePattern":"--list must be positive","errorType":"validation","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py","lineNumber":608,"sourceCode":"    )\n    return parser\n\n\ndef main() -> None:\n    \"\"\"Parse arguments, inspect the session store, and write JSON to stdout.\n\n    Raises:\n        SystemExit: If the command-line arguments are invalid, the local session\n            store is missing or unsupported, or the Deep Agents Code runtime\n            cannot be located.\n    \"\"\"\n    args = _build_parser().parse_args()\n    if args.max_content < 1:\n        msg = \"--max-content must be positive\"\n        raise SystemExit(msg)\n    if args.list_limit is not None and args.list_limit < 1:\n        msg = \"--list must be positive\"\n        raise SystemExit(msg)\n    if args.list_limit is None and not args.thread_id:\n        msg = \"Provide a thread ID or use --list N\"\n        raise SystemExit(msg)\n    if args.list_limit is not None and args.thread_id:\n        msg = \"Use either a thread ID or --list N, not both\"\n        raise SystemExit(msg)\n\n    _ensure_runtime()\n    warnings.filterwarnings(\n        \"ignore\",\n        message=(\n            \"Core Pydantic V1 functionality isn't compatible with Python 3.14 \"\n            \"or greater.*\"\n        ),\n    )\n    collected_warnings: list[str] = []\n    result: dict[str, object]\n    conn = _connect_read_only(args.db)","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/built_in_skills/deepagents-thread-inspector/scripts/inspect_sessions.py#L590-L626","documentation":"Argument validation in `main()`: when `--list N` is used, N must be >= 1. A non-positive list size is nonsensical (can't list 0 threads), so the CLI exits.","triggerScenarios":"Running `inspect_sessions.py --list 0` or `--list -5`.","commonSituations":"Scripted usage where a limit variable was unset or computed as 0; misunderstanding `--list` as a boolean toggle and passing 0.","solutions":["Pass a positive integer: `--list 20`","Omit the value handling by just using `--list` with its intended count","If you want all threads, use a sufficiently large N rather than 0"],"exampleFix":"// before\ninspect_sessions.py --list 0\n// after\ninspect_sessions.py --list 20","handlingStrategy":"validation","validationCode":"list_n = parse_list_arg()\nif list_n is not None and list_n < 1:\n    list_n = 10  # or raise before invoking","typeGuard":"def is_valid_list_limit(v: object) -> bool:\n    return v is None or (isinstance(v, int) and not isinstance(v, bool) and v >= 1)","tryCatchPattern":"try:\n    run_inspector(list_limit=n)\nexcept SystemExit as e:\n    if \"--list must be positive\" in str(e):\n        run_inspector(list_limit=10)\n    else:\n        raise","preventionTips":["Guard scripted limit values for >= 1 before invoking","Don't treat --list as a boolean flag with value 0","Default to a sane positive N when the limit is unknown"],"tags":["cli","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}