Support all types of field values, including all-digit single-select IDs #8
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.
Problem
A single select option id is an 8-character hexadecimal value (e.g.
47fc9ee4).There's a 2.3% chance that this id will be comprised only of digits (e.g.
12345678): (10/16)^8 = 0.0232If an option id is comprised of digits only, this action cannot set the field to this value.
Investigation Results
The underlying
gh api graphqlfield update call is doing an automatic conversion of values that look like integers (source):It leads to this kind of error (
98236657in the example is an option ID (VALUE_TO_SET) passed in as-F value="$VALUE_TO_SET":{ "errors": [ { "extensions": { "value": 98236657, "problems": [ { "path": [], "explanation": "Could not coerce value 98236657 to String" } ] }, "locations": [ { "line": 1, "column": 50 } ], "message": "Variable $value of type String was provided invalid value" } ] }Solution
Switching from direct value passing to reading the value from
stdinsince it bypasses the conversion and treats the passed value as a string.