Skip to content

Fix: roza -a fails after setting --first-roza-date#30

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-prayer-times-fetching
Draft

Fix: roza -a fails after setting --first-roza-date#30
Copilot wants to merge 3 commits intomainfrom
copilot/fix-prayer-times-fetching

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 19, 2026

When --first-roza-date is set, roza -a and roza --number N use fetchCustomRamadanDays which fired 30 parallel requests to the AlAdhan API — one per Ramadan day. This saturates the API's rate limit, returning non-standard error responses that fail Zod's ApiEnvelopeSchema validation (code field missing → "Required"), causing all three fallback methods to fail simultaneously. Without --first-roza-date, roza -a uses a single bulk Hijri calendar call and never hits this limit.

Changes

  • fetchCustomRamadanDays rewritten to use the Gregorian monthly calendar API (calendarByAddress / calendarByCity) instead of 30 individual timing calls. A 30-day Ramadan period spans at most 2 calendar months, so this reduces the call count from 30 → 1–2.

  • fetchGregorianMonthCalendar added — mirrors the fallback chain pattern of fetchRamadanCalendar (address → city).

  • toApiDateString added — formats a Date to DD-MM-YYYY to match AlAdhan API date keys used for day lookup after fetching the monthly calendar.

// Before: 30 concurrent requests → rate-limited
return Promise.all(days.map(dayDate => fetchRamadanDay(query, dayDate)));

// After: 1–2 bulk monthly calendar requests
const monthCalendars = await Promise.all(
  uniqueMonths.map(({ year, month }) => fetchGregorianMonthCalendar(query, year, month))
);
  • api.test.ts: added test for fetchCalendarByAddress.
Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: Prayer times not fetched after changing the first date</issue_title>
<issue_description>## Description

After changing the first date, the application fails to fetch prayer times.
This happens even though the same configuration works before the date change.

Error Output

roza -a

✖ Could not fetch prayer times. timingsByAddress failed: Invalid API response: Required | timingsByCity failed: Invalid API response: Required | timingsByCoords failed: Invalid API response: Required

</issue_description>

Comments on the Issue (you are @copilot in this section)

@ahmadawais Try resetting.

Feel free to send in a PR.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 19, 2026 14:39
Co-authored-by: ahmadawais <960133+ahmadawais@users.noreply.github.com>
Co-authored-by: ahmadawais <960133+ahmadawais@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug with fetching prayer times after date change Fix: roza -a fails after setting --first-roza-date Feb 19, 2026
Copilot AI requested a review from ahmadawais February 19, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Prayer times not fetched after changing the first date

2 participants