Skip to content

Conversation

rjan90
Copy link
Contributor

@rjan90 rjan90 commented Sep 19, 2025

Proposed Changes

Improve error handling in lotus info command for disabled payment channels. Use both errors.Is() and string matching to detect ErrPaymentChannelDisabled, preventing exit code 1 when EnablePaymentChannelManager is false.

This change fixes automation script failures (reported by the ChainSafe team) that occurred because the command previously exited with code 1 instead of 0 when payment channels were disabled (by default).

Checklist

Before you mark the PR ready for review, please make sure that:

@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz Sep 19, 2025
@rjan90 rjan90 force-pushed the phi/fix-cli-info-err branch from 29191f1 to 18793ab Compare September 19, 2025 15:38
…o command

fix(cli): improve error handling for disabled payment channels in info command
@rjan90 rjan90 force-pushed the phi/fix-cli-info-err branch from 18793ab to fe92fd7 Compare September 19, 2025 15:39
@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting Review in FilOz Sep 23, 2025
@rjan90 rjan90 marked this pull request as ready for review September 23, 2025 06:49
@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 06:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves error handling in the lotus info command for disabled payment channels to prevent automation script failures. The change ensures the command exits with code 0 instead of code 1 when payment channels are disabled by default.

  • Updated error message text for ErrPaymentChannelDisabled to be more concise
  • Enhanced error detection logic to use both errors.Is() and string matching for robustness

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
node/impl/paych/paych.go Updated error message text for ErrPaymentChannelDisabled to be more concise
cli/info.go Added dual error detection using both errors.Is() and string matching to handle disabled payment channels

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

cli/info.go Outdated
Comment on lines 148 to 150
// Use both errors.Is and string comparison for robustness
if errors.Is(err, paych.ErrPaymentChannelDisabled) ||
strings.Contains(err.Error(), "payment channels disabled") {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string matching approach is fragile and creates tight coupling between the error message text and the error handling logic. If the error message changes in the future, this condition could break. Consider using only errors.Is() for type-safe error detection, or if string matching is necessary for backwards compatibility, use a constant for the string to avoid magic strings.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a constant PaymentChannelDisabledMessage in 3d6b865

- Add PaymentChannelDisabledMessage constant to avoid magic strings
- Update CLI error handling to use the constant instead of hardcoded string
- Improves maintainability and reduces coupling between error message and logic
@rjan90 rjan90 added the skip/changelog This change does not require CHANGELOG.md update label Sep 23, 2025
@BigLep BigLep requested a review from rvagg September 23, 2025 13:52
@rvagg
Copy link
Member

rvagg commented Sep 23, 2025

We should just be able to use the errors.Is for this but the catch is that the error needs to traverse the RPC boundary, we do that by registering error types in api/api_errors.go so both sides of the RPC know to encode it with a number, and decode it from that number, then it appears on the client side as the same error type and errors.Is works. Then we can do away with the string constant exported and just put the string into the error itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip/changelog This change does not require CHANGELOG.md update
Projects
Status: 🔎 Awaiting Review
Development

Successfully merging this pull request may close these issues.

2 participants