build_product_details: skip non-finite prices instead of raising OverflowError #26

Merged
dsql merged 1 commits from development into main 2026-10-10 03:24:57 +00:00
Owner

Completes #25, which guarded calculate_priority but not the same calculation in runner.py build_product_details. On 2026-10-09 06:25Z an infinite price raised OverflowError there and stopped discord-consumer's API deal loop (CRITICAL "api deal loop stopped"). Non-finite prices (both paths) and an unrepresentable ratio now skip with a warning. Tests fail before / pass after (tests/test_build_product_details.py: 25 passed). Rebuild every monitor-utils consumer with --no-cache.

Completes #25, which guarded calculate_priority but not the same calculation in runner.py build_product_details. On 2026-10-09 06:25Z an infinite price raised OverflowError there and stopped discord-consumer's API deal loop (CRITICAL "api deal loop stopped"). Non-finite prices (both paths) and an unrepresentable ratio now skip with a warning. Tests fail before / pass after (tests/test_build_product_details.py: 25 passed). Rebuild every monitor-utils consumer with --no-cache.
dsql added 1 commit 2026-10-10 03:24:57 +00:00
PR #25 guarded calculate_priority but missed the same calculation here.
On 2026-10-09 06:25:50Z the consumer hit a product with an infinite price;
runner.py:201

    percentage = int(((original_price - current_price) / original_price) * 100)

raised `OverflowError: cannot convert float infinity to integer`. The
Discord leg dropped that one alert, but the API leg's caller does not
catch OverflowError, so the exception escaped and the consumer logged
CRITICAL "api deal loop stopped" -- no deals reached the API from then on
(nothing sent at all after 22:00Z), while the bot itself stayed "alive".

build_product_details now returns None (with a warning, like the
existing missing-price skip) when either price is a non-finite float, on
BOTH paths: the MSRP-less path never computes a percentage and would
otherwise carry inf into the Product and the API payload. A finite pair
whose ratio still overflows (a subnormal original price) is skipped too.
Ints and other types keep their existing behaviour.

Tests (tests/test_build_product_details.py): five new cases fail on the
old code -- OverflowError, ValueError for nan, and the MSRP-less case
building a Product with inf -- and all 25 pass now. Ruff findings on the
two files are unchanged from main (5, all pre-existing).

Rebuild every service that installs monitor-utils with --no-cache to pick
this up (it is pulled unpinned from main).

Co-Authored-By: Claude Code Opus 5.5 (ansible-ops, auto-repair) <noreply@anthropic.com>
Signed-off-by: disqualifier <dev@disqualifier.me>
dsql merged commit 1120083e45 into main 2026-10-10 03:24:57 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: pl_devs/monitor-shared-utils#26