alfred_clipsaver_workflow icon indicating copy to clipboard operation
alfred_clipsaver_workflow copied to clipboard

Fix: Boolean variable conversion fails with recycled string values

Open xu20160924 opened this issue 4 months ago • 1 comments

Why Change

The save_to_current checkbox variable was always reverting to 'false' after the first workflow run, breaking the "Save images to current Finder window" feature. The envvar_to_bool() function only handled numeric strings ('0', '1') from checkbox inputs but failed when Alfred recycled the string boolean values ('true', 'false') that the workflow itself output. The conversion int('true') raised a ValueError, caught by the exception handler, and defaulted to 0.

How Change

Enhanced envvar_to_bool() to explicitly handle both numeric strings ('0', '1') AND string boolean values ('true', 'false', 'yes', 'no') before attempting integer conversion. Added proper None and empty string handling with graceful fallback for unexpected values.

What Changed

  • wf_common.py: Rewrote envvar_to_bool() with explicit string matching

Testing

Tested on macOS 15.0+ with Alfred 5.x. Verified correct behavior with:

  • Checkbox inputs ('0', '1')
  • Recycled variables ('true', 'false')
  • Edge cases (None, empty string, 'yes', 'no')

Fixes save_to_current checkbox persistence across workflow executions.

xu20160924 avatar Oct 24 '25 06:10 xu20160924

Thanks for the PR @xu20160924 - I'm not quite sure how you were hitting this code path (I might be misunderstanding, but I wasn't able to reproduce it). Still, I took a look at the envvar_to_bool() function and adjusted it to be more robust.

Please give 2.7.2 a try and let me know if it works for you.

luckman212 avatar Oct 27 '25 18:10 luckman212