Skip to content

Refactor API fetchers to throw on failure instead of returning status objects #4096

Description

@anupcowkur

Fetchers in app/api/api_calls.ts wrap results in { status, data } objects that every hook in app/query/hooks.ts must translate back into TanStack Query state. An incomplete translation led to a crash crash (see #4097) where a
failed fetch resolved a query as success with null data. The hooks now throw on anything other than Success and the legitimate empty states, but the translation step itself should go.

  • Fetchers throw on failure and return plain data on success, so hooks become
    queryFn: fetchTeamsFromServer with no status mapping.
  • Legitimate empty states (NoApps, NoData, NotOnboarded, NoBuilds) stay
    representable as return values, for example a discriminated union.
  • Components tracking Init/Loading enum members migrate to TanStack's own
    statuses, then the *ApiStatus enums get deleted.

Touches app/api/api_calls.ts, app/query/hooks.ts, app/stores/filters_store.ts, and components that use status enums for UI state. Done when failures always travel as exceptions, no *ApiStatus enums
remain, and the unit and MSW integration suites pass.

Metadata

Metadata

Assignees

Labels

frontendfrontend relatedrefactorrefactoring tasks

Type

No type

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions