Bug: Division by zero in processAndStore when source data is empty #5
Посилання в новій задачі
Заблокувати користувача
Видалити гілку "%!s()"
Видалення гілки є незворотним. Хоча видалена гілка може продовжувати існувати ще деякий час до того, як її буде видалено остаточно, у більшості випадків це НЕМОЖЛИВО скасувати. Продовжити?
Bug
In
internal/imgcache/service.go,processAndStore()computes a size ratio:When
fetchBytesis 0 (e.g., empty cached source content, or a zero-length upstream response that somehow passed validation), this causes a division by zero, producing+InforNaNwhich gets logged and could cause issues with metrics/monitoring systems.Additionally, in
processFromSourceOrFetch(), when source data is loaded from cache,fetchBytesis set toint64(len(sourceData))which will be 0 for empty data, and this is passed toprocessAndStore().Impact
Panics won't occur (Go float division by zero produces Inf), but:
+InforNaNwhich breaks log parsingFix
Add a guard for
fetchBytes == 0before the division, and also validate that source data is non-empty before attempting to process it.