10
310
Fork
You've already forked codeberg-cli
33

fix: handle empty optional fields and non-interactive mode #254

Closed
timstoop wants to merge 3 commits from timstoop:fix-release-create-flags into main
pull from: timstoop:fix-release-create-flags
merge into: Aviac:main
Aviac:main
Contributor
Copy link

Fixes #249

This PR fixes issues where create commands would fail in non-interactive mode when all optional fields were provided via flags.

Changes

Central Fix

  • Modified multi_fuzzy_select_with_key() to return empty vec when called with empty list instead of erroring
  • Added unit tests for empty list behavior

Non-Interactive Mode Fixes

  • Fixed berg pull create to skip interactive prompts in non-interactive mode
  • Fixed berg milestone create to skip interactive prompts in non-interactive mode

Tests

  • Added integration test for pull create in non-interactive mode
  • Added integration test for milestone create in non-interactive mode

Fixed Commands

  • berg release create (already had non-interactive check)
  • berg pull create
  • berg issue create (already had non-interactive check)
  • berg milestone create
  • berg label create (already had non-interactive check)

Before

Commands would fail with:

There's nothing to select from
Caused by:
 The input device is not a TTY

After

Commands work correctly in non-interactive mode when all required fields are provided via flags.

Fixes #249 This PR fixes issues where create commands would fail in non-interactive mode when all optional fields were provided via flags. ## Changes ### Central Fix - Modified `multi_fuzzy_select_with_key()` to return empty vec when called with empty list instead of erroring - Added unit tests for empty list behavior ### Non-Interactive Mode Fixes - Fixed `berg pull create` to skip interactive prompts in non-interactive mode - Fixed `berg milestone create` to skip interactive prompts in non-interactive mode ### Tests - Added integration test for `pull create` in non-interactive mode - Added integration test for `milestone create` in non-interactive mode ## Fixed Commands - `berg release create` (already had non-interactive check) - `berg pull create` ✅ - `berg issue create` (already had non-interactive check) - `berg milestone create` ✅ - `berg label create` (already had non-interactive check) ## Before Commands would fail with: ``` There's nothing to select from Caused by: The input device is not a TTY ``` ## After Commands work correctly in non-interactive mode when all required fields are provided via flags.
Fixes #249
When all optional fields are provided via flags, the multi-select
prompt was called with an empty list, causing "Available options
can not be empty" error.
Instead of checking for empty optional_data in each command, handle
it centrally in the multi_fuzzy_select_with_key function.
This fixes the issue in:
- berg release create
- berg pull create
- berg issue create
- berg milestone create
- berg label create
Added unit tests to verify empty list behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes bug where pull create and milestone create commands would fail
in non-interactive mode with "The input device is not a TTY" error,
even when all required fields were provided via flags.
The commands were unconditionally calling multi_fuzzy_select_with_key()
for optional fields without checking if in non-interactive mode.
Changes:
- Wrap optional field selection in non-interactive check for pull create
- Wrap optional field selection in non-interactive check for milestone create
- Add integration tests for both commands in non-interactive mode
Related to #249 which fixed the same issue for other commands.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Aviac left a comment
Owner
Copy link

It is a deliberate choice to make it error out there since the interactive code is only supposed to be called whenever there are choices. Otherwise it should just never call the fuzzy select to begin with

It is a deliberate choice to make it error out there since the interactive code is only supposed to be called whenever there are choices. Otherwise it should just never call the fuzzy select to begin with
Changed approach based on maintainer feedback: instead of making
multi_fuzzy_select_with_key handle empty lists, check at call sites
to ensure the function is only called when there are items to select.
- Added checks in pull_request/create.rs and milestone/create.rs
- Updated multi_fuzzy_select_with_key to error with helpful message
- Removed tests for empty list behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Author
Contributor
Copy link

Updated the approach based on your feedback. Instead of making multi_fuzzy_select_with_key handle empty lists, I now check at the call sites before invoking it. The function will error with a helpful message directing users to file a bug if it's ever called incorrectly.

Updated the approach based on your feedback. Instead of making `multi_fuzzy_select_with_key` handle empty lists, I now check at the call sites before invoking it. The function will error with a helpful message directing users to file a bug if it's ever called incorrectly.
Author
Contributor
Copy link

Ah I see you already solved it in upstream, thanks for the feedback anyway!

Ah I see you already solved it in upstream, thanks for the feedback anyway!
timstoop closed this pull request 2025年10月12日 14:22:22 +02:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Aviac/codeberg-cli!254
Reference in a new issue
Aviac/codeberg-cli
No description provided.
Delete branch "timstoop:fix-release-create-flags"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?