Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix CircleCI v2 throw error when fetching approval job #1125

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

Kesin11
Copy link
Owner

@Kesin11 Kesin11 commented Mar 11, 2024

fix: #1120

CircleCI job detail API will fail with 404 when trying to fetch an approval job.
Previously CIAnalyzer would throw an error and stop when fetching this type of job. This PR fixes this problem by ignoring the approval job.

# Show workflow jobs that include approval job (job_number: 11257)
$ curl -sS -u "$CIRCLECI_TOKEN:" https://circleci.com/api/v2/workflow/e3beb02d-56b1-4756-8c4b-3e1142abf0f9/job
{
  "next_page_token" : null,
  "items" : [ {
    "dependencies" : [ ],
    "job_number" : 11256,
    "id" : "49edd5ca-f340-46fa-9457-7b3621f3bb3a",
    "started_at" : "2024-03-11T14:56:45Z",
    "name" : "lint",
    "project_slug" : "gh/Kesin11/CIAnalyzer",
    "status" : "success",
    "type" : "build",
    "stopped_at" : "2024-03-11T14:56:59Z"
  }, {
    "dependencies" : [ ],
    "job_number" : 11257,
    "id" : "130074c4-6d17-464b-a517-1e6089cbd89d",
    "started_at" : "2024-03-11T14:56:43Z",
    "name" : "hold",
    "approved_by" : "c0b37cd5-9ac5-4bae-b701-c71026c0ed5a",
    "project_slug" : "gh/Kesin11/CIAnalyzer",
    "status" : "success",
    "type" : "approval",
    "stopped_at" : "2024-03-11T14:57:08Z",
    "approval_request_id" : "130074c4-6d17-464b-a517-1e6089cbd89d"
  }, {
    "dependencies" : [ "130074c4-6d17-464b-a517-1e6089cbd89d", "49edd5ca-f340-46fa-9457-7b3621f3bb3a" ],
    "job_number" : 11259,
    "id" : "bec90601-96ae-4d4c-a3d3-0bed583a503a",
    "started_at" : "2024-03-11T14:57:12Z",
    "name" : "build_and_test",
    "project_slug" : "gh/Kesin11/CIAnalyzer",
    "status" : "success",
    "type" : "build",
    "stopped_at" : "2024-03-11T14:58:00Z"
  } ]

# API response is 404
$ curl -sS -u "$CIRCLECI_TOKEN:" https://circleci.com/api/v2/project/github/Kesin11/CIAnalyzer/job/11257
{
    "message": "Job not found."
}

@Kesin11 Kesin11 added the bug Something isn't working label Mar 11, 2024
@Kesin11 Kesin11 merged commit bfb0edb into master Mar 11, 2024
8 checks passed
@Kesin11 Kesin11 deleted the circleciv2_ignore_approval_job branch March 11, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to manage 404 responses by CircleCI
1 participant