Skip to content

Migrate remaining Server Actions to ActionResult<T> pattern #102

Description

@ryota-murakami

Summary

PR #100 introduced ActionResult<T> discriminated union type and converted github.ts and user-presets.ts. The remaining Server Action files should be incrementally migrated to this pattern.

Why ActionResult

  • Discriminated unions ({ success: true; data: T } | { success: false; error: string }) provide compile-time safety that { data: T | null; error: string | null } cannot. TypeScript narrows the type after checking result.success, so you can safely access result.data or result.error without null checks.
  • withAuthResult<T> wraps the try/catch + Sentry reporting in one place, so every server action gets consistent error handling for free. The auth check returns a result object instead of throwing, which means callers never need try/catch for auth failures.

Remaining Files

board.ts (client-consumed functions)

  • createBoard — called from CreateBoardForm.tsx (currently throws)
  • updateBoardPositions — called from BoardGrid.tsx (currently throws)

shared-project-info.ts → project-info.ts / maintenance-project-info.ts

  • upsertProjectInfoCore → wrapper upsertProjectInfo (currently throws)
  • updateCommentCore → wrapper updateComment (currently throws)
  • updateCommentColorCore → wrapper updateCommentColor (currently throws)
  • deleteCommentCore → wrapper deleteComment (currently throws)
  • getProjectInfoCore → wrapper getProjectInfo (currently throws on DB error)

repo-cards.ts (type alignment only)

  • Already uses { success, error } pattern — just add ActionResult<T> return type annotations

Scope

  • DO NOT convert internal/server-component-only functions (e.g., getStatusLists, getBoardData, fetchBoardInitialData) — these can stay throw-based since server components have error boundaries
  • DO NOT convert auth.ts — uses redirect(), special flow
  • DO NOT convert useActionState functions — they have specific state shapes required by the hook

Source

Established pattern in PR #100 (refactor/error-handling-68), src/lib/actions/types.ts

Activity

  1. added 2 commits that reference this issue on Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3-lowBacklog / nice to havebackendServer Actions, database, APIenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions