fix: coerce sleep_requests and numeric settings from string form values

`sleep_requests` (and other numeric inheritable video download settings)
could arrive as strings ('' or '0.75') from the frontend NumberInputForm
and DownloadRequest bodies. These were persisted into Download.settings
(JSONB) and later triggered:

    if effective['sleep_requests'] > 0:
    TypeError: '>' not supported between instances of 'str' and 'int'

in VideoDownloader.execute_download (and similar sites).

Root cause: DownloadSettings.__post_init__ only filtered None/[] and did
no type coercion, even though the dataclass declared Optional[float]/int.

Changes (minimal targeted fix):
- Add _coerce_optional_number helper and apply it to all numeric fields
  in DownloadSettings.__post_init__ (the existing sanitization boundary).
- Centralize legacy string coercion for persisted data in the single
  read chokepoint: get_effective_video_settings.
- Simplify VideoDownloaderConfig.sleep_requests getter.
- Frontend: use parseFloat for type=number inputs + null defaults for
  sleep_requests (prevents '' from ever being submitted).
- Add focused regression test for string coercion path.
- Revert unrelated change to string field filtering behavior.

No NaN/Inf speculation, no duplicated try/float guards at every call site,
no behavior change for non-numeric settings.
This commit is contained in:
Roland 2026-05-31 12:43:56 -06:00 • committed by lrnselfreliance
parent cd9fb4c6de
commit 9cc5c15e32
8 changed files with 111 additions and 12 deletions

View file

@ -563,7 +563,7 @@ export function VideosDownloadForm({
writethumbnail: false,
writeinfojson: false,
yt_dlp_extra_args: '',
sleep_requests: '',
sleep_requests: null,
user_agent: '',
continue_dl: false,
nooverwrites: false,
@ -849,7 +849,7 @@ export function ChannelDownloadForm({
writethumbnail: false,
writeinfojson: false,
yt_dlp_extra_args: '',
sleep_requests: '',
sleep_requests: null,
user_agent: '',
},
sub_downloader: Downloaders.Video,
@ -1214,7 +1214,7 @@ export function RSSDownloadForm({download, submitter, onDelete, onCancel, action
writethumbnail: false,
writeinfojson: false,
yt_dlp_extra_args: '',
sleep_requests: '',
sleep_requests: null,
user_agent: '',
},
tag_names: [],