Skip to content

AdminPage's fetchOswEvents silently swallows fetch errors, unlike the adjacent fetchEcosystems #888

Description

@Jagadeeshftw

Description

src/features/admin/pages/AdminPage.tsx defines two very similar list-loading functions right next to each other. fetchEcosystems correctly surfaces failures to the admin:

const fetchEcosystems = async () => {
  try {
    setIsLoading(true)
    setErrorMessage(null)
    const response = await getAdminEcosystems()
    setEcosystems(response.ecosystems || [])
    setEcosystemsVisibleCount(clampLimit(ECOSYSTEMS_PAGE_SIZE))
  } catch (error) {
    logger.error('Failed to fetch ecosystems:', error)
    setEcosystems([])
    setErrorMessage(error instanceof Error ? error.message : 'Failed to load ecosystems.')
  } finally {
    setIsLoading(false)
  }
}

but fetchOswEvents, called from the same useEffect on mount, does not:

const fetchOswEvents = async () => {
  try {
    setIsOswLoading(true)
    const res = await getAdminOpenSourceWeekEvents()
    setOswEvents(res.events || [])
    setOswVisibleCount(clampLimit(OSW_EVENTS_PAGE_SIZE))
  } catch (e) {
    setOswEvents([])
  } finally {
    setIsOswLoading(false)
  }
}

If getAdminOpenSourceWeekEvents() fails (network error, 500, auth expiry, etc.), the catch block silently resets oswEvents to an empty array with no logging and no errorMessage/toast — an admin sees an indistinguishable "no events" empty state instead of being told the request failed, and has no way to tell a real "zero events configured" state apart from "the fetch broke."

Requirements

  • fetchOswEvents's catch block must log the error (matching fetchEcosystems's logger.error call) and surface a user-visible error state for the Open-Source Week events section.
  • The error state must be distinguishable from a genuine empty list (see the related issue about handleCreateOsw/handleDeleteOswConfirmed reusing the wrong errorMessage state — this should use a dedicated OSW-scoped error state rather than reusing the ecosystems' errorMessage).

Suggested execution

  1. Fork the repo and create a branch: git checkout -b fix/adminpage-osw-events-fetch-error-handling
  2. Add an oswErrorMessage state (mirroring errorMessage) and set it in fetchOswEvents's catch block, alongside a logger.error call.
  3. Render the OSW error state near the Open-Source Week events section, matching the ecosystems section's existing error banner pattern.
  4. Add a test asserting a rejected getAdminOpenSourceWeekEvents() call surfaces a visible error rather than a silent empty list.

Example commit message

fix: surface fetchOswEvents failures instead of silently swallowing them

Acceptance criteria

  • A failed Open-Source Week events fetch logs the error and shows a visible error message to the admin.
  • The error state is visually distinguishable from a genuine empty events list.
  • A test covers the failure path.

Security notes

None directly, but silently hiding fetch failures can mask backend/auth problems from admins, which is worth flagging in review.

Guidelines

  • Minimum 95% test coverage
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuebugSomething isn't workingfrontendFrontend / UI work

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions