Fix GitHubReview state values to match the GitHub API - #1525
Open
Socialpranker wants to merge 1 commit into
Open
Fix GitHubReview state values to match the GitHub API#1525Socialpranker wants to merge 1 commit into
Socialpranker wants to merge 1 commit into
Conversation
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 danger#1443
Contributor
Author
|
The red
|
fbartho
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHubReview.statewas typed as"APPROVED" | "REQUEST_CHANGES" | "COMMENT" | "PENDING", but the reviews API doesn't sendREQUEST_CHANGESorCOMMENT. It sendsCHANGES_REQUESTEDandCOMMENTED, which is why the check in #1443 silently never matches:DISMISSEDwas missing too, so a dismissed review had no valid type either.On the shape of the fix: @orta suggested keeping the literal array and adding
| string, and checking GitHub's own OpenAPI description makes that the right call rather than just a lenient one.pull-request-review.statethere is a plaintype: stringwithCHANGES_REQUESTEDas the example, with no enum, so GitHub deliberately doesn't commit to a closed set. A fully exact union would still be wrong even with the names corrected. The literals give you autocomplete, and| stringstops the type from claiming a guarantee GitHub doesn't make.One side effect worth flagging:
source/danger-incoming-process-schema.jsonis generated bytypescript-json-schema, and adding| stringdrops theenumfrom that property, leaving"type": "string". That's the honest description now, since the old enum listed two values GitHub never sends and would reject the two it does. Nothing validates against that schema at runtime; it's there for otherdanger-processimplementations.The regenerated
danger.d.tsand schema are included.source/dsl/GitHubDSL.tsalso picked up two unrelated formatting hunks (author_associationindentation and a trailing space) because lint-staged runs prettier over the whole staged file on commit.Ran the full suite: 682 passing. Note that the tests don't run on Node 25 at all on main, since
buffer-equal-constant-timereadsSlowBuffer.prototypewhich Node 25 removed, so 32 suites fail to load before any test executes. On Node 22 everything is green.Written with Claude Code (Claude Opus 5); I reviewed and tested everything before submitting.