Fix image placeholder URLs #5
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
背景 / 问题
在图像生成场景里,偶发会返回类似
/images/p_Lw的图片链接;p_Lw解码后等价于路径/,客户端拉取必然 404,表现为“黑色小占位图/坏图”。从 Worker 日志可观察到大量
GET /images/p_Lw -> 404,且这些请求并非上游限流,而是本地把空/占位的generatedImageUrls当成了最终图片 URL 提前结束导致。原因
上游(Grok imagine)是 NDJSON 流式输出,某些中间帧会先出现
modelResponse.generatedImageUrls,但其中可能包含空字符串/占位值(如""或"/")。旧逻辑只要看到
generatedImageUrls是数组就直接生成图片链接并结束,导致把占位值编码成p_Lw返回给客户端。修改
generatedImageUrls:忽略空字符串/纯空白 URL。.gitignore增加.ace-tool/,避免本地索引文件误入仓库。影响
/images/p_Lw这类坏链接,客户端不再出现黑色占位图。This pull request improves the way generated image URLs are handled and normalized in the
src/grok/processor.tsfile. The changes ensure that only valid, non-empty string URLs are processed, which prevents issues with empty or malformed image links in downstream logic.Improvements to image URL handling:
normalizeGeneratedAssetUrlsto filter and clean up thegeneratedImageUrlsarray, ensuring only valid, trimmed string URLs are returned.createOpenAiStreamFromGrokNdjsonandparseOpenAiFromGrokNdjsonto usenormalizeGeneratedAssetUrlsinstead of directly accessing or checking the type ofgeneratedImageUrls. This streamlines URL processing and avoids duplicate logic. [1] [2]parseOpenAiFromGrokNdjsonto keep scanning for usable URLs, preventing the return of broken image links when only empty or placeholder URLs are present.