Skip to content

Cleanup step shows 'Bad credentials' error when prepare phase fails #858

@gireesh-fractal

Description

@gireesh-fractal

Description

When the prepare phase of the action fails (e.g., due to track_progress being used with an unsupported event type), the post-run cleanup step still attempts to delete the installation token, resulting in a confusing "Bad credentials" error in the logs.

Steps to Reproduce

  1. Configure workflow with track_progress: true
  2. Trigger via workflow_dispatch (unsupported event for track_progress)
  3. Observe prepare phase fails with:
    ##[error]Prepare step failed with error: track_progress is only supported for events: pull_request, issues, issue_comment, pull_request_review_comment, pull_request_review. Current event: workflow_dispatch
    
  4. Cleanup step then runs and shows:
    curl -L \
      -X DELETE \
      -H "Accept: application/vnd.github+json" \
      -H "Authorization: Bearer " \
      ...
    {
      "message": "Bad credentials",
      "documentation_url": "https://docs.github.com/rest",
      "status": "401"
    }
    

Note the empty token value after "Authorization: Bearer ".

Expected Behavior

The cleanup step should check if a token was successfully acquired before attempting to delete it:

if [ -n "$TOKEN" ]; then
  curl -L -X DELETE ...
fi

Actual Behavior

Cleanup runs unconditionally, resulting in a 401 error that can confuse users debugging workflow failures.

Impact

  • Cosmetic/low severity - doesn't affect functionality
  • Makes logs harder to interpret when debugging failures
  • Users may think there's a credentials/permissions issue when the real error is elsewhere

Environment

  • Action version: v1
  • Event: workflow_dispatch
  • Runner: ubuntu-latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdev-experiencep3Minor bug or general feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions