Skip to content

Don't mask a sync error with NoMethodError when there is no TTY - #20

Open
pcbeingused333 wants to merge 1 commit into
Rails-Designer:mainfrom
pcbeingused333:fix/sync-noninteractive-cleanup
Open

pcbeingused333 wants to merge 1 commit into
Rails-Designer:mainfrom
pcbeingused333:fix/sync-noninteractive-cleanup

Conversation

@pcbeingused333

Copy link
Copy Markdown

The bug

Sync#now wraps the sync in rescue => error and calls post_error_clean_up:

def post_error_clean_up
  print "Do you want to remove the temp files? ... [y/n]: "
  response = $stdin.gets.chomp.downcase
  ...

Run non-interactively — CI, cron, rake icons:sync | tee log$stdin.gets returns nil, so nil.chomp raises NoMethodError. Because this runs inside the rescue, it replaces the real sync failure and skips the raise at the end of now.

The fix

Guard the nil. With no TTY, keep the temp files (the safe default) and let the original error propagate.

Tests

sync_test.rbpost_error_clean_up with an empty/EOF stdin keeps the files (no NoMethodError); with "y" it still removes them. The first fails on main (NoMethodError). bundle exec rake is green (91 runs, 0 failures).

🤖 Generated with Claude Code

`Sync#now` rescues a failed sync and calls `post_error_clean_up`, which
does `$stdin.gets.chomp.downcase`. Run non-interactively (CI, cron, a
piped `rake`), `$stdin.gets` returns `nil`, so `nil.chomp` raises
`NoMethodError` from inside the rescue -- replacing the real error with a
confusing one and skipping the `raise`.

Guard the `nil`: with no TTY, keep the temp files and let the original
error surface.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtYgwYNfJ3wHrw9xrooVoB
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.

1 participant