Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

An empty `imageUrl=`, `logoUrl=` or `template=` returns an error instead of the default

Geschlossen Anfängerfreundlich
#166 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@Saifjafri212213 arbeitet bereits daran.

Seit 21.10.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
api, backend

Rechercherichtung

Beginne in src/lib/api-validation.ts mit dem Vergleich der bestehenden Vorverarbeitung von width und height mit den Schemas für template, logoUrl und imageUrl. Prüfe die Schema-Tests in tests/api/og.test.ts und anschließend die Routentests, die den Renderer mocken. Fertig ist es, wenn leere Werte Standardwerte verwenden, ungültige nichtleere URLs weiterhin 400 zurückgeben und die Schema- und Routentests diese Fälle abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug good first issue hacktoberfest

/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:

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.preprocess for logoUrl, imageUrl and template, so an empty value counts as missing. template= then gets blog-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), logoUrl and imageUrl (lines 14 and 15), and the width/height preprocess (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= renders blog-minimal-dark
  • imageUrl=not-a-url still returns 400
  • Tests for the schema and for the route
  • npm run check, npm run test and npm run build pass

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.

Vorherrschende Sprache
TypeScript
Sterne
8
Forks
4
Ø Merge
5 Std. 44 Min.
Gemergte PRs (30 T.)
83

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/ogcops

Alle Issues in codercops/ogcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.