fix(worker): 修复 dedup fingerprint JSON 序列化失败 - np.float32 转原生 float #239

Merged
xiaoxia merged 1 commits from fix/dedup-float32-json into develop 2026-07-13 08:54:58 +08:00
Owner

问题

GeneratedVideo 查重记录创建失败,报错 float32 is not JSON serializable

根因

cv2.normalize() 返回 np.float32 数组,color_histograms 直接存进 VideoFingerprint.to_dict() 后,SQLAlchemy JSON 字段序列化时 Python 原生 json.dumps 不支持 numpy 类型。

修复

VideoFingerprint.to_dict() 中统一转 Python 原生类型:

  • color_histograms: np.float32float
  • duration: 统一转 float
  • resolution: np.int32int

影响范围

  • generate_video 任务:查重记录创建
  • render_edit_plan 任务:查重记录创建
## 问题 GeneratedVideo 查重记录创建失败,报错 `float32 is not JSON serializable`。 ## 根因 `cv2.normalize()` 返回 `np.float32` 数组,`color_histograms` 直接存进 `VideoFingerprint.to_dict()` 后,SQLAlchemy JSON 字段序列化时 Python 原生 `json.dumps` 不支持 numpy 类型。 ## 修复 `VideoFingerprint.to_dict()` 中统一转 Python 原生类型: - `color_histograms`: `np.float32` → `float` - `duration`: 统一转 `float` - `resolution`: `np.int32` → `int` ## 影响范围 - `generate_video` 任务:查重记录创建 - `render_edit_plan` 任务:查重记录创建
xiaoxia added 1 commit 2026-07-13 08:41:31 +08:00
fix(worker): 修复 dedup fingerprint JSON 序列化失败 - np.float32 转原生 float
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 55s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 1m39s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m8s
1ccec767d1
根因:cv2.normalize() 返回 np.float32 数组,color_histograms 直接存进 dict 后
SQLAlchemy JSON 序列化时报 'float32 is not JSON serializable'

修复:VideoFingerprint.to_dict() 中统一转 Python 原生类型
- color_histograms: np.float32 → float
- duration: 统一转 float
- resolution: np.int32 → int
xiaoxia force-pushed fix/dedup-float32-json from 7ad8f43575 to 1ccec767d1 2026-07-13 08:41:31 +08:00 Compare
xiaoxia merged commit 9b2e782abd into develop 2026-07-13 08:54:58 +08:00
Sign in to join this conversation.