Repository navigation
Closed
Labels
bugSomething isn't workinggh-projectrelating to the gh project commandhelp wantedContributions welcomepriority-2Affects more than a few users but doesn't prevent core functions
Description
Describe the bug
Here's another case that I found out for
--numberthat 0 is discarded as an invalid value:$ bin/gh project item-edit --project-id $projectId --id $itemId --field-id $fieldId --number 0 error: no changes to makeHowever, given above valid ranges, it is a valid value and can be set from UI:
Originally posted by @iamazeem in #10342
As stated in the issue, this appears to prevent users from accidentally setting item field values to zero due to zero value for float flags:
cli/pkg/cmd/project/item-edit/item_edit.go
Lines 79 to 96 in 756ba75
| if err := cmdutil.MutuallyExclusive( | |
| "only one of `--text`, `--number`, `--date`, `--single-select-option-id` or `--iteration-id` may be used", | |
| opts.text != "", | |
| opts.number != 0, | |
| opts.date != "", | |
| opts.singleSelectOptionID != "", | |
| opts.iterationID != "", | |
| ); err != nil { | |
| return err | |
| } | |
| if err := cmdutil.MutuallyExclusive( | |
| "cannot use `--text`, `--number`, `--date`, `--single-select-option-id` or `--iteration-id` in conjunction with `--clear`", | |
| opts.text != "" || opts.number != 0 || opts.date != "" || opts.singleSelectOptionID != "" || opts.iterationID != "", | |
| opts.clear, | |
| ); err != nil { | |
| return err | |
| } |
cli/pkg/cmd/project/item-edit/item_edit.go
Lines 148 to 155 in 756ba75
| // update item values | |
| if config.opts.text != "" || config.opts.number != 0 || config.opts.date != "" || config.opts.singleSelectOptionID != "" || config.opts.iterationID != "" { | |
| return updateItemValues(config) | |
| } | |
| if _, err := fmt.Fprintln(config.io.ErrOut, "error: no changes to make"); err != nil { | |
| return err | |
| } |
Affected version
2.66.1
Steps to reproduce the behavior
- Create v2 project with
Numberfields - Add issue to project
gh project item-edit --project-id $projectId --id $itemId --field-id $fieldId --number 0
Expected vs actual behavior
When a user calls gh project item-edit and --number 0 is explicitly set, then we allow the item field value to be set to zero.
Logs
$ GH_DEBUG=api ./bin/gh project item-edit --project-id PVT_kwDOBWmBn84Al2QA --id PVTI_lADOBWmBn84Al2QAzgXCZ4c --field-id PVTF_lADOBWmBn84Al2QAzgnpmgo --number 0
error: no changes to makeReacted by Azeem
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggh-projectrelating to the gh project commandhelp wantedContributions welcomepriority-2Affects more than a few users but doesn't prevent core functions

Activity
andyfeller commentedon Feb 6, 2025
Initial thoughts
Rather than simply checking
opts.number != 0, I think the right way to solve this is to also see if the flag ischangedor not.For example:
BagToad commentedon Feb 6, 2025
Acceptance Criteria
Given I have a V2 project with a number field
When I run
gh project item-editwith the--number 0argThen the item field value is correctly set to zero
@andyfeller I'm going to call this triaged and add the
help wantedflag, but please feel free to correct the A/C or labels if I got anything wrong 🙏iamazeem commentedon Feb 7, 2025
cmd.Flags().Changed("number")won't be accessible for the rest of the flow.For example:
cli/pkg/cmd/project/item-edit/item_edit.go
Line 149 in 756ba75
cli/pkg/cmd/project/item-edit/item_edit.go
Line 175 in 756ba75
Any ideas or preferences for these cases?
aryanbhosale commentedon Feb 10, 2025
Does #10417 fix this?