{"record":{"id":"aa1bc8ec77467d9a","repo":"unslothai/unsloth","slug":"media-auto-unload-idle-seconds-must-be-0-off-or","errorCode":null,"errorMessage":"Media auto-unload idle seconds must be 0 (off) or at least {MIN_AUTO_UNLOAD_IDLE_SECONDS}.","messagePattern":"Media auto-unload idle seconds must be 0 \\(off\\) or at least (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/utils/openai_auto_switch_settings.py","lineNumber":308,"sourceCode":"    if parsed_enabled is None:\n        raise ValueError(\"OpenAI auto-switch must be true or false.\")\n    parsed_idle = None\n    if idle_seconds is not None:\n        parsed_idle = _coerce_int(idle_seconds)\n        if parsed_idle is None:\n            raise ValueError(\"Auto-unload idle seconds must be a non-negative integer.\")\n        if 0 < parsed_idle < MIN_AUTO_UNLOAD_IDLE_SECONDS:\n            raise ValueError(\n                f\"Auto-unload idle seconds must be 0 (off) or at least \"\n                f\"{MIN_AUTO_UNLOAD_IDLE_SECONDS}.\"\n            )\n    parsed_media_idle = None\n    if media_idle_seconds is not None:\n        parsed_media_idle = _coerce_int(media_idle_seconds)\n        if parsed_media_idle is None:\n            raise ValueError(\"Media auto-unload idle seconds must be a non-negative integer.\")\n        if 0 < parsed_media_idle < MIN_AUTO_UNLOAD_IDLE_SECONDS:\n            raise ValueError(\n                f\"Media auto-unload idle seconds must be 0 (off) or at least \"\n                f\"{MIN_AUTO_UNLOAD_IDLE_SECONDS}.\"\n            )\n    parsed_keep_kv = None\n    if keep_kv is not None:\n        parsed_keep_kv = _coerce_bool(keep_kv)\n        if parsed_keep_kv is None:\n            raise ValueError(\"Keep KV on idle unload must be true or false.\")\n    parsed_auto_download = None\n    if auto_download is not None:\n        parsed_auto_download = _coerce_bool(auto_download)\n        if parsed_auto_download is None:\n            raise ValueError(\"Auto-download missing models must be true or false.\")\n    parsed_api_only = None\n    if api_only is not None:\n        parsed_api_only = _coerce_bool(api_only)\n        if parsed_api_only is None:\n            raise ValueError(\"Auto-unload API-loaded only must be true or false.\")","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/openai_auto_switch_settings.py#L290-L326","documentation":"Raised by set_openai_auto_switch in openai_auto_switch_settings.py:307-311. media_idle_seconds obeys the same floor as the main idle: 0 (off) or >= MIN_AUTO_UNLOAD_IDLE_SECONDS (60). Values 1..59 are rejected so media workloads cannot trigger rapid load/unload cycles.","triggerScenarios":"set_openai_auto_switch(enabled=True, media_idle_seconds=45) — any value in 1..59. media_idle_seconds=0 or >=60 passes; negatives were clamped to 0 earlier.","commonSituations":"Tuning media pipeline memory reclaim too aggressively (e.g. 15s); sliders permitting sub-minute values; default configs copied from an older version with a lower minimum.","solutions":["Use 0 to disable media auto-unload or pick a value >= 60","Clamp the UI control to 0 or [60, infinity)","Normalize before calling: v = 0 if 0 < v < 60 else v is wrong for 'off' semantics — instead reject and prompt the user"],"exampleFix":"# before\nset_openai_auto_switch(enabled=True, media_idle_seconds=45)\n\n# after\nset_openai_auto_switch(enabled=True, media_idle_seconds=90)","handlingStrategy":"validation","validationCode":"def valid_media_idle(v: int) -> bool:\n    return v == 0 or v >= 60  # MIN_AUTO_UNLOAD_IDLE_SECONDS","typeGuard":"def is_valid_media_idle(v: object) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and (v == 0 or v >= 60)","tryCatchPattern":"try:\n    set_openai_auto_switch(enabled=True, media_idle_seconds=media_idle)\nexcept ValueError as exc:\n    return {\"ok\": False, \"error\": str(exc)}, 400","preventionTips":["Reuse the same slider rules as the main idle: 0 or >= 60","Validate before submit and disable the save button","Explain the floor in the field's help text"],"tags":["settings","validation","range-check"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}