Skip to content

fix(api): normalize list query responses to arrays#317

Closed
volcano303 wants to merge 1 commit intoentrius:testfrom
volcano303:fix/api-array-query-normalization
Closed

fix(api): normalize list query responses to arrays#317
volcano303 wants to merge 1 commit intoentrius:testfrom
volcano303:fix/api-array-query-normalization

Conversation

@volcano303
Copy link
Copy Markdown
Contributor

@volcano303 volcano303 commented Apr 15, 2026

Summary

  • normalize list-style API query responses to arrays before exposing them to UI consumers
  • harden shared list query hooks used by search, dashboard, repositories, miners, and issues views
  • prevent render-time crashes when the test API returns a non-array payload for list endpoints

Related Issues

Follow-up to the page-only theme token refactor PR (#263).
Addresses runtime crashes such as:

  • miners.map is not a function
  • allPRs.forEach is not a function

Type of Change

  • Bug fix
  • Refactor
  • New feature
  • Documentation
  • Other (describe below)

Checklist

  • New components are modularized/separated where sensible
  • Responsive/mobile checked where relevant
  • npm run format:check has been run
  • npm run lint has been run
  • npm run build passes

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 15, 2026

Closing — the backend list endpoints already return arrays; guarding every consumer with ensureArray adds boilerplate for a scenario that doesn't occur in practice. If a specific endpoint is misbehaving, that should be fixed at the API layer.

@anderdc anderdc closed this Apr 15, 2026
@volcano303
Copy link
Copy Markdown
Contributor Author

Hi, @anderdc

I rechecked this on a clean local checkout of the current test branch, and there is still a reproducible runtime crash without the follow-up guard work.

Repro:

  1. checkout latest test
  2. run npm run dev
  3. open the app locally

Observed error:

  • miners.map is not a function
  • thrown from GlobalSearchBar via useSearchResults / buildMinerSearchData

So I agree the previous ensureArray / useArrayApiQuery PR was too broad and not the right abstraction for every list hook. But some fix still seems required, because the current frontend on test is crashing against the current runtime payload it receives.

I can rework this into a much narrower follow-up PR limited to the specific failing path instead of normalizing every list endpoint globally. If you prefer this to be fixed strictly at the backend/API contract layer instead, I’m fine with that too, but I wanted to call out that the crash is currently reproducible on test. 😅

@anderdc anderdc added the refactor Code restructuring without behavior change label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants