Error Handling When Asana or GitHub API Calls Fail in the github-asana-request-review-action

The action implements a fail-fast strategy where every Asana or GitHub API error is immediately checked, wrapped with context using fmt.Errorf(": %w", err), and bubbled up to the top-level Handler.Handle function, causing the GitHub Action step to fail without retries or fallbacks.

The keitap/github-asana-request-review-action repository synchronizes GitHub pull request review activity with Asana tasks through a Go-based implementation. When integrating with external APIs, robust error handling is critical to prevent silent failures and ensure CI/CD pipelines surface issues immediately. This analysis examines the specific patterns used to handle failures when communicating with the Asana and GitHub APIs.

Immediate Error Detection and Wrapping Pattern

Every external request to Asana or GitHub is treated as a potentially failing operation. All SDK methods return an error value that is inspected immediately using the standard Go idiom. When an error is detected, the function wraps the original error with fmt.Errorf(": %w", err) to preserve the error chain and facilitate debugging.

This pattern appears consistently throughout the codebase, particularly in handler.go. For example, when fetching the requestor's account or upserting reviewers:

// Pattern found in handler.go lines 66-70 and 58-62
if err != nil {
    return fmt.Errorf("failed to fetch account: %w", err)
}

The wrapped error provides context while maintaining the original error type for inspection by the GitHub Actions runtime.

Error Propagation Through the Handler Layer

The action uses explicit error return values rather than exception handling. Errors bubble up from low-level SDK calls through intermediate helpers until they reach the entry point. In handler.go, every significant operation follows this validation pattern:

  • Fetching the requestor (lines 66-70): Wraps errors from Handler.fetchAccount when retrieving GitHub user details.
  • Upserting a reviewer (lines 58-62 and 66-70): Handles failures from Handler.updateReviewers when synchronizing reviewer state.
  • Upserting PR comments (lines 84-92): Manages errors during comment creation or updates in AddPullRequestCommentToTask.

The Handler.Handle method serves as the top-level dispatcher that delegates to handlePullRequestEvent or handlePullRequestReviewEvent. When any downstream function returns an error, Handle propagates it outward, causing the GitHub Action step to fail with a non-zero exit code.

Asana SDK Error Handling

Asana API interactions occur through dedicated helper functions that forward raw SDK errors to the handler layer. These include AddPullRequestCommentToTask, FindTaskComment, UpdateTaskComment, AddCodeReviewSubtask, UpdateCodeReviewSubtask, FindSubtaskByName, and AddCodeReviewSubtaskComment.

These helpers interact with Asana resources using methods such as:

  • task.CreateComment
  • task.Stories
  • task.Subtasks
  • client.CreateTask
  • subtask.Update
  • subtask.CreateComment

The raw errors from these Asana client methods are propagated back to the caller without transformation, ensuring the original error context—including HTTP status codes and Asana error messages—remains available for debugging.

GitHub API Error Handling

GitHub API errors are captured in methods including Handler.updateReviewers, Handler.handlePullRequestReviewEvent, and Handler.fetchAccount. These functions call GitHub client methods such as getRequestedReviewers, getReviewCommentCount, and user account fetching operations.

Similar to the Asana layer, GitHub client errors are wrapped with fmt.Errorf(": %w", err) and returned immediately. This halts further processing when authentication fails, rate limits are exceeded, or network errors prevent API access. The error handling ensures that partial state changes are not committed when GitHub data cannot be retrieved.

No Retry Logic or Fallback Mechanisms

The implementation deliberately omits retry mechanisms, exponential backoff, or circuit breaker patterns. When an API call fails—whether due to network glitches, rate limiting, or malformed responses—the action stops immediately rather than attempting recovery.

This "fail fast" approach ensures that transient failures do not create inconsistent state between GitHub and Asana. The error message appears directly in the GitHub Actions workflow logs, making integration issues visible to developers without masking the root cause through complex recovery logic.

Summary

  • Immediate error checking: Every API call result is tested with if err != nil before proceeding to dependent operations.
  • Contextual wrapping: Errors are wrapped using fmt.Errorf(": %w", err) to maintain the error chain while adding descriptive context.
  • Handler entry point: The Handler.Handle function manages all error propagation, returning failures to the GitHub Actions runtime to mark steps as failed.
  • No recovery logic: The action does not implement retries, fallbacks, or circuit breakers—API failures stop execution immediately.
  • Source locations: Critical error handling logic resides in handler.go (specifically lines 58-70 and 84-92) and various Asana helper functions that forward SDK errors.

Frequently Asked Questions

Does the action retry failed API requests?

No. The github-asana-request-review-action does not implement retry logic for either Asana or GitHub API calls. When a request fails due to network issues, rate limiting, or invalid credentials, the error is wrapped and returned immediately, causing the action step to fail. This design prioritizes visibility of integration issues over automatic recovery attempts.

How are API errors logged in the GitHub Actions output?

Errors bubble up through the call stack to the Handler.Handle function, which returns them to the GitHub Actions runtime. The wrapped error messages—including those processed through fmt.Errorf(": %w", err) in handler.go lines 58-92—are printed to the workflow logs with their full context, allowing developers to trace failures back to specific API calls.

What happens if the Asana API returns a rate limit error?

The action treats rate limit errors like any other API failure. The Asana SDK returns the error through methods like task.CreateComment or subtask.Update, which propagate through helper functions such as AddPullRequestCommentToTask back to the handler. Without retry logic, the action exits immediately with a failure status, requiring manual re-run once the rate limit resets.

Is there any fallback mechanism if GitHub API calls fail?

No fallback mechanisms exist. If calls to getRequestedReviewers or account fetching fail within Handler.updateReviewers or Handler.fetchAccount, the error is wrapped and returned immediately. The action cannot complete its synchronization task without successful GitHub API access, so it fails fast rather than operating on stale or incomplete data.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →