Skip to content

Fix release-build panic in resolve_color_choice#220

Merged
popematt merged 1 commit into
amazon-ion:mainfrom
popematt:main
May 22, 2026
Merged

Fix release-build panic in resolve_color_choice#220
popematt merged 1 commit into
amazon-ion:mainfrom
popematt:main

Conversation

@popematt
Copy link
Copy Markdown
Contributor

Issue #, if available:

None

Description of changes:

When testing Ion CLI before publishing the 0.12.0 release, I discovered a bug. It turns out that a function I had been using as a guard to prevent panics is actually a no-op when you do a release build, so all my previous testing had missed it.

Clap's try_contains_id relies on verify_arg which is gated behind #[cfg(debug_assertions)], so it always returns Ok(()) in release builds. Commands that don't register --color/--no-color (e.g., inspect) would pass the guard, then get_flag("color") would panic because the arg was never configured with ArgAction::SetTrue.

The fix uses try_get_one::<bool> with pattern matching. For SetTrue args, clap stores a default value, so Ok(Some(&false)) means "registered but not passed" while Ok(None) (release) or Err (debug) means "never registered." The wildcard arm returns ColorChoice::Never, preserving the original semantics.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@popematt popematt merged commit fa6f1f0 into amazon-ion:main May 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants