fix(jd_client): handle invalid tp_address gracefully instead of panicking#213
fix(jd_client): handle invalid tp_address gracefully instead of panicking#213jayvaliya wants to merge 1 commit into
Conversation
|
@Priceless-P, could you please review when you have a moment? |
There was a problem hiding this comment.
thanks for looking into this. two things:
- maybe it is best to do
SocketAddr::from_strinstead of the split and then extract ip/addr, or even better - make the code useSocketAddrall along - (bonus) when we extract the address we should validate the node is reachable
39ac408 to
e743923
Compare
|
Hi @jbesraa, thank you for the earlier feedback. I have addressed the requested changes:
Could you please review again when you have a moment? |
jbesraa
left a comment
There was a problem hiding this comment.
Thanks @jayvaliya
Just a added a couple of nits
| .or_else(|| std::env::var("TP_ADDRESS").ok()); | ||
| let tp_address = tp_address.map(|tp| { | ||
| let addr = tp.parse::<std::net::SocketAddr>().unwrap_or_else(|e| { | ||
| eprintln!("Invalid TP address '{tp}': {e}. Expected format: 'ip:port' (e.g., '127.0.0.1:8442')"); |
There was a problem hiding this comment.
| eprintln!("Invalid TP address '{tp}': {e}. Expected format: 'ip:port' (e.g., '127.0.0.1:8442')"); | |
| error!("Invalid TP address '{tp}': {e}. Expected format: 'ip:port' (e.g., '127.0.0.1:8442')"); |
| std::process::exit(1); | ||
| }); | ||
| if let Err(e) = std::net::TcpStream::connect_timeout(&addr, std::time::Duration::from_secs(3)) { | ||
| eprintln!("Warning: TP address '{addr}' is not reachable: {e}"); |
There was a problem hiding this comment.
| eprintln!("Warning: TP address '{addr}' is not reachable: {e}"); | |
| error!("Error: TP address '{addr}' is not reachable: {e}"); |
hmm dont we need to process:exit here as well?
|
please also squash the changes into a single commit @jayvaliya |
|
Thanks for the reminder, and sorry about the premature review request. I accidentally clicked it before applying your requested changes. I’ll make the updates and re-request review once they’re pushed. |
|
BTW one thing to note here, if the user enters template provider address and it is invalid(or inaccessible), we NEED to exit and print an error. if the user does not enter TP address at all, we should allow it(in that case proxy is not doing JD) |
e743923 to
059b547
Compare
|
Hi @jbesraa, thank you again for your detailed feedback and patience. I’ve addressed all requested changes, pushed the updates, and squashed the PR into a single commit. Please let me know if any further changes are needed. I’d appreciate your review when convenient. |
059b547 to
83e3188
Compare
|
Hi @jbesraa, I’ve pushed the latest updates and resolved the issues with all three workflow commands:
Everything should be working properly now. Happy to make further adjustments if needed. |
611a282 to
9b4787e
Compare
|
Hi @Priceless-P, @jbesraa just a gentle follow-up when you have a moment. I’ve addressed the feedback, rebased it on the latest master, and re-checked the workflow commands. I’d appreciate your review whenever you have time. |
9b4787e to
87f2dda
Compare
…king Closes dmnd-pool#212 - Switch tp_address from String to SocketAddr end-to-end - Validate TP address format at startup with clear error message - Exit with error if TP address is invalid or unreachable - Remove manual split/parsing logic in JD client - Allow proxy to run without TP address (non-JD mode)
87f2dda to
d97e18e
Compare
|
Updated library_init.rs to match the The CI was failing on Fixed by changing to - Some(tp_sniffer_addr.to_string()),
+ Some(tp_sniffer_addr),This was the only remaining cause of the clippy/test failures — This additional change to library_init.rs was needed to align the test with the |
|
Hi @jbesraa, everything’s good now, no conflicts and all checks are passing. Appreciate a review when you have a moment. |
Closes #212
Description:
Summary
Fixes two gaps in error handling for
--tp-address:config.rs — Added
validate_tp_address()called at config load time, giving users an immediate clear error on startup (mirrors the existingvalidate_miner_name()pattern).jd_client/mod.rs — Replaced three panicking
.expect()calls (lines 110–111, 208–209) with gracefulmatch+return None, consistent with the 15 other error paths already in initialize_jd().Changes
validate_tp_address()+ call after loading tp_address.expect()withmatch+return None