Repository navigation
gh project item-edit should allow explicit --number 0 field values #10380
Description
Activity
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:
if err := cmdutil.MutuallyExclusive( "only one of `--text`, `--number`, `--date`, `--single-select-option-id` or `--iteration-id` may be used", opts.text != "", cmd.Flags().Changed("number"), opts.date != "", opts.singleSelectOptionID != "", opts.iterationID != "", ); err != nil { return err }
- addedgh-projectrelating to the gh project commandrelating to the gh project command
on Feb 6, 2025 Acceptance Criteria
Given I have a V2 project with a number field
When I rungh project item-editwith the--number 0arg
Then 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 🙏Reacted by Azeem- addedhelp wantedContributions welcomeContributions welcomepriority-2Affects more than a few users but doesn't prevent core functionsAffects more than a few users but doesn't prevent core functionsand removedneeds-triageneeds to be reviewedneeds to be reviewed
on 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:
if err := cmdutil.MutuallyExclusive( "only one of `--text`, `--number`, `--date`, `--single-select-option-id` or `--iteration-id` may be used", opts.text != "", cmd.Flags().Changed("number"), opts.date != "", opts.singleSelectOptionID != "", opts.iterationID != "", ); err != nil { return err }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
if config.opts.text != "" || config.opts.number != 0 || config.opts.date != "" || config.opts.singleSelectOptionID != "" || config.opts.iterationID != "" { cli/pkg/cmd/project/item-edit/item_edit.go
Line 175 in 756ba75
} else if config.opts.number != 0 { Any ideas or preferences for these cases?
Does #10417 fix this?
Describe the bug
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
cli/pkg/cmd/project/item-edit/item_edit.go
Lines 148 to 155 in 756ba75
Affected version
2.66.1Steps to reproduce the behavior
Numberfieldsgh project item-edit --project-id $projectId --id $itemId --field-id $fieldId --number 0Expected vs actual behavior
When a user calls
gh project item-editand--number 0is explicitly set, then we allow the item field value to be set to zero.Logs