An empty `imageUrl=`, `logoUrl=` or `template=` returns an error instead of the default
Maintainer thường phản hồi trong vòng 1 ngày
@Saifjafri212213 đang làm issue này rồi.
Từ ngày 21/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Bắt đầu trong src/lib/api-validation.ts bằng cách so sánh bước tiền xử lý hiện có của width và height với các schema của template, logoUrl và imageUrl. Kiểm tra các bài kiểm thử schema trong tests/api/og.test.ts, sau đó là các bài kiểm thử route mô phỏng renderer. Công việc hoàn tất khi các giá trị rỗng dùng giá trị mặc định, URL không rỗng nhưng không hợp lệ vẫn trả về 400, và các bài kiểm thử schema cùng route bao quát những trường hợp đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
/api/og treats an empty parameter as "use the default": title= or bgColor= with nothing after them still give the normal image. Three parameters don't:
- https://og.codercops.com/api/og?template=blog-photo-overlay&imageUrl= returns 400
{"error":"imageUrl: Invalid url"}. WithoutimageUrl=, the same template renders with its gradient background. logoUrl=returns 400{"error":"logoUrl: Invalid url"}with any template, for example https://og.codercops.com/api/og?template=blog-minimal-dark&logoUrl= (no template readslogoUrlyet, but the schema still checks it).- https://og.codercops.com/api/og?template= returns 404
{"error":"Template \"\" not found"}. The API docs say the default template isblog-minimal-dark(src/pages/api-docs.astro, line 68), and that's what you get whentemplateis left out.
This is easy to hit when the URL is built from CMS data, like imageUrl={{ post.cover }} on a post without a cover image: the whole OG image fails instead of falling back.
In src/lib/api-validation.ts, logoUrl and imageUrl (lines 14 and 15) are z.string().url().optional(). .optional() only covers a missing key, so an empty string goes on to .url() and fails. template (line 4) uses .default('blog-minimal-dark'), which also only applies when the key is missing. width and height (lines 16 to 23) already handle this: z.preprocess turns '' into undefined before the rest of the check.
What to do
- Use the same
z.preprocessforlogoUrl,imageUrlandtemplate, so an empty value counts as missing.template=then getsblog-minimal-dark, and the two URLs fall back to the template's defaults. - A value that's there but isn't a URL, like
imageUrl=not-a-url, should still return 400.
Where to look
src/lib/api-validation.ts:template(line 4),logoUrlandimageUrl(lines 14 and 15), and thewidth/heightpreprocess (lines 16 to 23)src/pages/api/og.ts: the 400 for invalid params (lines 41 to 47) and the 404 for an unknown template (lines 61 to 70)tests/api/og.test.ts: the schema tests (line 11) and the route tests, which mock the renderer (from line 269)
Acceptance criteria
-
?template=blog-photo-overlay&imageUrl=and?logoUrl=return the same image as leaving the parameter out -
?template=rendersblog-minimal-dark -
imageUrl=not-a-urlstill returns 400 - Tests for the schema and for the route
-
npm run check,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #166 in the description.
- Ngôn ngữ chính
- TypeScript
- Star
- 8
- Fork
- 4
- Merge trung bình
- 6 giờ 9 phút
- Pull request đã merge (30 ngày)
- 66
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của codercops/ogcops
-
accessibility bug good first issue hacktoberfest ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
accessibility bug good first issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue hacktoberfest ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
codercops/ogcops#167 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
codercops/ogcops#164 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/ogcops
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
chaitin/MonkeyCode#1437 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
rtdb-info-connected-order test: unhandled 'connection is closed' rejection fails the CLI suiteĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
carbon-design-system/carbon-ai-chat#2615 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
redhat-developer/rhdh-plugin-export-overlays#4486 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlineCó thể đã có người làm @r2jaff đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ComposioHQ/composio#5054 ·
Maintainer thường phản hồi trong vòng 1 ngày