From 9c2370f91578184a720ff7d99b6fd354bf15abd4 Mon Sep 17 00:00:00 2001 From: Socialpranker <273312799+Socialpranker@users.noreply.github.com> Date: Wed, 29 Jul 2026 20:06:33 +0200 Subject: [PATCH] Fix GitHubReview state values to match the GitHub API The type listed REQUEST_CHANGES and COMMENT, but the reviews API returns CHANGES_REQUESTED and COMMENTED, so checks like reviews.find(review => review.state === 'REQUEST_CHANGES') never matched. DISMISSED was missing entirely. GitHub's own OpenAPI description types this field as a plain string with no enum, so a closed union would be wrong even with the names corrected. The literals stay for autocomplete and `| string` keeps the type honest about values GitHub may add later. Fixes #1443 --- CHANGELOG.md | 2 ++ source/danger-incoming-process-schema.json | 8 +------ source/danger.d.ts | 9 +++++--- source/dsl/GitHubDSL.ts | 27 ++++++++++++---------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 606e2a7aa..952a2f8a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ +- `github.reviews` now reports the review states GitHub actually sends, so checking for a review that requested changes works - fixes [#1443](https://github.com/danger/danger-js/issues/1443) [@Socialpranker] - Upgrade to undici 6.27.0 to resolve transitive CVEs - fixes [#1517](https://github.com/danger/danger-js/issues/1517) [@rjatkins] @@ -2146,6 +2147,7 @@ Not usable for others, only stubs of classes etc. - [@orta] [@sharkysharks]: https://github.com/sharkysharks [@shyim]: https://github.com/shyim [@snowe2010]: https://github.com/snowe2010 +[@socialpranker]: https://github.com/Socialpranker [@sogame]: https://github.com/sogame [@soyn]: https://github.com/Soyn [@stefanbuck]: https://github.com/stefanbuck diff --git a/source/danger-incoming-process-schema.json b/source/danger-incoming-process-schema.json index e75b8edf7..8de41c1bb 100644 --- a/source/danger-incoming-process-schema.json +++ b/source/danger-incoming-process-schema.json @@ -1888,13 +1888,7 @@ "type": "number" }, "state": { - "description": "The state of the review\nAPPROVED, REQUEST_CHANGES, COMMENT or PENDING", - "enum": [ - "APPROVED", - "COMMENT", - "PENDING", - "REQUEST_CHANGES" - ], + "description": "The state of the review, e.g. APPROVED, CHANGES_REQUESTED, COMMENTED,\nDISMISSED or PENDING. GitHub does not document a closed set of values for\nthis field, so it is typed as a union with `string` rather than an exact\none: the literals give you autocomplete, and `string` keeps the type honest\nabout values GitHub may add.", "type": "string" }, "user": { diff --git a/source/danger.d.ts b/source/danger.d.ts index 85a5fd4c4..d8efe0ba1 100644 --- a/source/danger.d.ts +++ b/source/danger.d.ts @@ -1450,10 +1450,13 @@ interface GitHubReview { commit_id?: string /** - * The state of the review - * APPROVED, REQUEST_CHANGES, COMMENT or PENDING + * The state of the review, e.g. APPROVED, CHANGES_REQUESTED, COMMENTED, + * DISMISSED or PENDING. GitHub does not document a closed set of values for + * this field, so it is typed as a union with `string` rather than an exact + * one: the literals give you autocomplete, and `string` keeps the type honest + * about values GitHub may add. */ - state?: "APPROVED" | "REQUEST_CHANGES" | "COMMENT" | "PENDING" + state?: "APPROVED" | "CHANGES_REQUESTED" | "COMMENTED" | "DISMISSED" | "PENDING" | string } /** Provides the current PR in an easily used way for params in `github.api` calls */ diff --git a/source/dsl/GitHubDSL.ts b/source/dsl/GitHubDSL.ts index 6c9c4831f..8c7cc79fb 100644 --- a/source/dsl/GitHubDSL.ts +++ b/source/dsl/GitHubDSL.ts @@ -289,13 +289,13 @@ export interface GitHubPRDSL { /** How does the PR author relate to this repo/org? */ author_association: - | "COLLABORATOR" - | "CONTRIBUTOR" - | "FIRST_TIMER" - | "FIRST_TIME_CONTRIBUTOR" - | "MEMBER" - | "NONE" - | "OWNER" + | "COLLABORATOR" + | "CONTRIBUTOR" + | "FIRST_TIMER" + | "FIRST_TIME_CONTRIBUTOR" + | "MEMBER" + | "NONE" + | "OWNER" } // These are the individual subtypes of objects inside the larger DSL objects above. @@ -450,10 +450,13 @@ export interface GitHubReview { commit_id?: string /** - * The state of the review - * APPROVED, REQUEST_CHANGES, COMMENT or PENDING + * The state of the review, e.g. APPROVED, CHANGES_REQUESTED, COMMENTED, + * DISMISSED or PENDING. GitHub does not document a closed set of values for + * this field, so it is typed as a union with `string` rather than an exact + * one: the literals give you autocomplete, and `string` keeps the type honest + * about values GitHub may add. */ - state?: "APPROVED" | "REQUEST_CHANGES" | "COMMENT" | "PENDING" + state?: "APPROVED" | "CHANGES_REQUESTED" | "COMMENTED" | "DISMISSED" | "PENDING" | string } /** Provides the current PR in an easily used way for params in `github.api` calls */ @@ -462,8 +465,8 @@ export interface GitHubAPIPR { owner: string /** The repo name */ repo: string - /** - * The PR number + /** + * The PR number * @deprecated use `pull_number` instead */ number: number