* fix(provider): disable OpenAI SDK built-in retries under AstrBot retry layer (#9663)
AsyncOpenAI/AsyncAzureOpenAI inherit the SDK default max_retries=2, which
nests underneath AstrBot's tenacity-based retry_provider_request(). As a
result provider_settings.request_max_retries no longer reflects the true
attempt count (e.g. request_max_retries=1 still sends up to 3 HTTP
requests) and delays fallback-provider switchover. Pass max_retries=0 so
AstrBot's retry layer is the single source of truth for retries.
* test(provider): add retry-count regression test, parameterize client retry tests
Address review feedback on #9669: merge the near-identical official/Azure
client construction tests into a parametrized test, and add a regression
test asserting _query() performs exactly request_max_retries attempts
through retry_provider_request() when the call keeps failing, guarding
against multiplicative retries being reintroduced.
* fix(media): guard oversized image inputs and attachment uploads
为模型图片输入与聊天附件上传增加大小护栏 / Add size guards for model
image inputs and chat attachment uploads:
- _convert_image_bytes_sync 复用原始编码字节的分支增加 2MB 上限;更大的
输入重编码,输出始终受像素尺寸与质量约束
- prepare_model_image 在读入前检查文件大小,超过 32MB 跳过并记录日志
- 聊天附件上传上限 100MB:路由先检查 Content-Length,服务层落盘后复核
实际大小
- Reuse the original encoded bytes in _convert_image_bytes_sync only for
stills up to 2MB; larger inputs are re-encoded so the output stays
bounded by pixel size and quality.
- prepare_model_image checks the file size before reading and skips
inputs above 32MB with a warning log.
- Chat attachment uploads are capped at 100MB: the route checks
Content-Length first, and save_uploaded_file re-checks the on-disk
size after saving.
Tests: tests/test_media_utils.py, tests/test_chat_route.py
* fix(media): sniff image headers instead of decoding for MIME detection
MIME 探测改为读取文件头魔数,不再解码整个图片 / Detect image MIME
types by reading header magic bytes instead of decoding the whole file:
- detect_image_mime_type 仅读取前 32 字节识别 PNG/JPEG/GIF/WebP/BMP/
TIFF/AVIF,内存占用与文件大小无关
- 聊天附件上传上限从 100MB 放宽到 512MB
- detect_image_mime_type reads only the first 32 bytes and recognizes
PNG/JPEG/GIF/WebP/BMP/TIFF/AVIF, so memory usage no longer scales
with file size
- Chat attachment upload limit raised from 100MB to 512MB
Tests: tests/test_media_utils.py
* test: remove obsolete image assertion and fix upload fixtures
* test: mock plugin marketplace requests in dashboard tests
---------
Co-authored-by: RuochenPan <badbatch0x01@gmail.com>