-
-
Notifications
You must be signed in to change notification settings - Fork 638
Improve release script OTP handling and retry logic #2045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
**Problem:** The release script was failing when publishing Ruby gems because OTP codes were being reused or expiring between NPM and RubyGems publications. The script would fail with "Your OTP code is incorrect" after successfully publishing NPM packages. **Solution:** 1. Added retry logic with up to 3 attempts for each gem publication 2. Added explicit 5-second delay between gem publications to prevent OTP code reuse 3. Added clear prompts reminding users to generate fresh OTP codes 4. Created ReleaseHelpers module to reduce code nesting and improve maintainability **Changes:** - Created `ReleaseHelpers.publish_gem_with_retry` helper method - Added retry logic for both react_on_rails and react_on_rails_pro gems - Added 5-second delay between gem publications - Improved error messages with actionable guidance - Maintained RuboCop compliance (no block nesting violations) **Benefits:** - More robust release process that handles transient OTP failures - Clear user guidance on generating fresh OTP codes - Automatic retry on failure (reduces manual intervention) - Better separation between OTP-requiring operations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 35 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review - PR #2045SummaryThis PR improves the reliability of the gem release process by adding retry logic for OTP failures and timing separation between gem publications. Overall, this is a solid improvement that addresses a real pain point in the release workflow. ✅ Strengths
🔍 Code Quality Observations1. Exception Handling Scope (Minor Issue)Location: The current implementation catches rescue Gem::CommandException, IOError => e
# Handle gem-specific and network errorsReasoning:
Impact: Low - unlikely to cause issues in practice, but more precise exception handling is a best practice. 2. OTP Timing AssumptionsLocation: The 5-second delay between gem publications (line 270 in the full file) is a good start, but the retry delay is only 3 seconds. Consider: # Current:
sleep 3 # Before retry
# Suggested:
sleep 5 # Match the inter-publication delayReasoning: OTP codes typically have 30-second windows. A 3-second delay might be too short if the issue is an expiring code rather than a network glitch. Consistency with the 5-second inter-publication delay would be clearer. 3. Module Function DeclarationLocation: Using module ReleaseHelpers
include ReactOnRails::TaskHelpers
module_function
def publish_gem_with_retry(dir, gem_name, max_retries: 3)
# ...
end
endImpact: None functionally, just style preference. 4. Hardcoded Retry CountLocation: The def publish_gem_with_retry(dir, gem_name, max_retries: ENV.fetch('GEM_RELEASE_MAX_RETRIES', '3').to_i)Impact: Low priority - current default is fine for most cases. 🧪 Testing ConsiderationsMissing Test Coverage: The release rake task has no automated tests. While this is understandable given its nature (interacts with external services), consider:
Example test structure: # spec/tasks/release_rake_spec.rb
RSpec.describe 'release rake task' do
describe ReleaseHelpers do
describe '.publish_gem_with_retry' do
it 'retries on failure' do
# Mock sh_in_dir to fail twice, then succeed
end
it 'raises after max retries' do
# Mock sh_in_dir to always fail
end
end
end
endPriority: Medium - This would prevent regressions in the retry logic. 🔒 Security Considerations✅ No security concerns identified. The code:
⚡ Performance ConsiderationsThe added delays (5 seconds between publications, 3 seconds between retries) are intentional and appropriate. Total worst-case delay:
This is acceptable for a release process that's not time-critical. 📝 Documentation & ChangelogGood: The PR body is comprehensive and includes a test plan. Suggestion: Since this improves the developer experience for maintainers (not end users), no CHANGELOG.md entry is needed per the project's guidelines:
However, consider adding a comment in the code explaining the 5-second delay rationale: # Add delay before next OTP operation to ensure:
# 1. Previous OTP code is fully consumed by RubyGems
# 2. User has time to generate a fresh OTP code
# OTP codes typically expire after 30 seconds
puts "\n⏳ Waiting 5 seconds before next publication to ensure OTP separation..."
sleep 5🎯 RecommendationsPriority: High
Priority: Medium (Follow-up PR or future improvement)
Priority: Low
✨ Final VerdictAPPROVED ✅ This PR successfully addresses a real pain point in the release process with a clean, maintainable solution. The retry logic and timing improvements will make releases more reliable. The minor suggestions above are nice-to-haves but not blockers. Great work on improving the developer experience! 🚀 Review generated with attention to the React on Rails CLAUDE.md guidelines |
Code Review: Improve release script OTP handling and retry logicSummaryThis PR adds retry logic and timing improvements to handle OTP failures during gem publication. The changes are well-structured and address a real pain point in the release process. ✅ Strengths
🔍 Potential Issues & Suggestions1. Broad Exception Handling (Medium Priority)Issue: Line 32 catches rescue StandardError => eRecommendation: Consider catching more specific exceptions related to gem publication failures. The
Example: rescue StandardError => e
retry_count += 1
# Log the actual error for debugging
puts "Error: #{e.class} - #{e.message}"
if retry_count < max_retries && otp_related_error?(e)
# retry logic
else
raise e
end
end2. Retry Sleep Timing Inconsistency (Low Priority)Issue: There's a 3-second delay between retries (line 40) but a 5-second delay between gem publications (line 271). Recommendation: Consider if the retry delay should match the inter-publication delay for consistency, or document why they differ. 3. User Experience: Prompt Before Retry (Low Priority)Issue: The script automatically retries without user confirmation. If an OTP fails, the user might need a moment to prepare a fresh code. Recommendation: Consider prompting the user before retrying: puts "\nPress ENTER to retry with a fresh OTP code, or Ctrl+C to cancel..."
$stdin.getsThis gives users time to generate a new OTP code rather than rushing them. 4. Testing ConsiderationsObservation: The PR mentions testing will happen during the next release. Recommendation: Consider adding:
🛡️ Security Considerations✅ No security issues identified. The code handles OTP codes appropriately without logging sensitive information. ⚡ Performance Considerations✅ No significant performance concerns. The delays (3s, 5s) are appropriate for OTP operations and won't meaningfully impact release time. 🧪 Test CoverageGap: No automated tests for the new Recommendation: Add specs in # spec/rake/release_helpers_spec.rb
RSpec.describe ReleaseHelpers do
describe '.publish_gem_with_retry' do
# Test successful publication
# Test retry on failure
# Test max retries exceeded
end
end📝 Code Style & Best Practices✅ Follows Ruby conventions: Good use of ✅ Consistent with codebase: Matches the existing style in 🎯 Overall AssessmentRating: ✅ Approve with minor suggestions This is a solid improvement to the release process that addresses a real pain point. The code is well-structured and maintainable. The suggestions above are mostly about error handling specificity and user experience polish - none are blockers. Recommended next steps:
Great work on improving the developer experience! 🎉 Review performed by Claude Code following React on Rails conventions from CLAUDE.md |
Code ReviewI've reviewed PR #2045 and have the following feedback: ✅ Strengths
🐛 Potential Issues1. Exception Handling Verification Neededbegin
sh_in_dir(dir, "gem release")
success = true
rescue StandardError => e
# ...
endAnalysis: The Recommendation: Test manually during next release, or add a comment confirming this catches Rake failures. 2. Missing Return ValueThe method doesn't explicitly return a value. While Suggestion: Add explicit return at the end: 3. Retry Delay May Be Too Short
Recommendation: Consider increasing to 5 seconds to give users adequate time. 🎯 Code Quality Observations
🧪 Testing ConcernsObservation: No tests exist for the release script. The retry logic involves exception handling, conditional branches, timing, and external commands. Recommendation: At minimum, manual testing during the next release to verify:
🔒 Security & Performance
📋 Suggestions
✅ VerdictAPPROVE with minor suggestions The PR effectively solves a real problem. The implementation is sound and follows repository conventions. Why approve:
Suggested follow-ups (non-blocking):
The code is ready to merge. 🚀 |
Summary
Problem
The release script was failing when publishing Ruby gems because OTP codes were being reused or expiring between NPM and RubyGems publications. The script would fail with "Your OTP code is incorrect" after successfully publishing NPM packages.
Solution
ReleaseHelpersmodule to reduce block nesting and improve maintainabilityChanges
ReleaseHelpers.publish_gem_with_retryhelper methodreact_on_railsandreact_on_rails_progemsBenefits
Test Plan
🤖 Generated with Claude Code