Skip to content

Issue #241 solved: report rejected TCP addresses in the event log - #242

Open
PRINCEKK122 wants to merge 1 commit into
oss-slu:mainfrom
PRINCEKK122:validation-failure-logging
Open

PRINCEKK122 wants to merge 1 commit into
oss-slu:mainfrom
PRINCEKK122:validation-failure-logging

Conversation

@PRINCEKK122

Copy link
Copy Markdown
Contributor

Closes #241.

Problem

connect_tcp_with_validation_and_save (relay/src/update.rs:13) validates the address before connecting. On failure it set tcp_addr_validation_error and returned without calling tcp_connect, so none of the paths that normally report a connection problem were reached. Pressing Connect TCP with a bad address left nothing in the event log.

The only feedback was one line of plain text from tcp_validation_text (relay/src/view.rs:192), sitting between the address box and the buttons. The event log panel added in #183 exists so connection failures are visible; this was the one connection failure that never reached it.

The empty-field case is the expensive one. validate_tcp_addr returned Invalid IP address. Use format: 127.0.0.1:9999 for an empty string, which reads as "you typed it wrong" when the greyed 127.0.0.1:9999 is placeholder text and nothing was typed at all.

Change

  • The validation failure is logged through log_event alongside the inline hint, so it appears in Recent events like every other connection failure.
  • An empty field gets its own message: No address entered. Type one, for example 127.0.0.1:9999.

Deliberately narrow: this changes only how a rejection is reported. Which address forms are accepted is #240's question, and the placeholder's wording is #239's.

Testing

cargo test passes, 10/10. Warning count unchanged from main.

Two tests added:

  • empty_address_is_reported_in_the_event_log — asserts the entry reaches event_log, that the inline message is the empty-field one rather than the typo one, and that no TCP thread was spawned.
  • malformed_address_is_reported_in_the_event_log — same for a malformed address. Uses 127.0.0.1 with no port rather than a host name, so the test stays valid whichever way Relay rejects host names, so a changing iMotions IP can't be entered as a name #240 goes.

Found while testing #234: about half an hour went to diagnosing a relay that appeared not to connect, with an empty address field and nothing in the log to work from.

connect_tcp_with_validation_and_save validates before connecting, and on
failure it set tcp_addr_validation_error and returned without calling
tcp_connect. None of the paths that normally report a connection problem
were reached, so the press left nothing in the event log. The only
feedback was one line of plain text between the address box and the
buttons, which is easy to miss.

Log the rejection like every other connection failure, and give an empty
field its own message. validate_tcp_addr returned "Invalid IP address"
for an empty string, which reads as a typo when the greyed 127.0.0.1:9999
is placeholder text and nothing was typed at all.

Tests cover both: an empty field and a malformed one each reach the event
log and leave no TCP thread behind.
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.

Connect TCP with an invalid address is silent in the event log

1 participant