Skip to content

fix: handle null firstName/lastName in setConnectedTo (#3)#40

Merged
ajacques merged 1 commit into
tryfi:masterfrom
prestomation:fix/null-name
Jun 27, 2026
Merged

fix: handle null firstName/lastName in setConnectedTo (#3)#40
ajacques merged 1 commit into
tryfi:masterfrom
prestomation:fix/null-name

Conversation

@prestomation

Copy link
Copy Markdown
Contributor
  • fix: handle null firstName/lastName in setConnectedTo

The TryFi API can return null for firstName or lastName on the user a collar is connected to (e.g. when the account email is stored as firstName with lastName=null). The previous code used string concatenation which raised TypeError: can only concatenate str (not NoneType) to str, causing the integration to fail setup.

Use .get() with empty string fallback and f-string interpolation instead of raw concatenation.

  • test: add unit tests for FiDevice.setConnectedTo

Tests cover all connection state types:

  • ConnectedToUser with both names present
  • ConnectedToUser with null lastName (the bug that caused TypeError)
  • ConnectedToUser with null firstName
  • ConnectedToUser with both names null
  • ConnectedToUser with missing name keys entirely
  • ConnectedToCellular with signal strength
  • ConnectedToBase with base ID
  • Unknown connection type returning None

* fix: handle null firstName/lastName in setConnectedTo

The TryFi API can return null for firstName or lastName on the user
a collar is connected to (e.g. when the account email is stored as
firstName with lastName=null). The previous code used string
concatenation which raised TypeError: can only concatenate str
(not NoneType) to str, causing the integration to fail setup.

Use .get() with empty string fallback and f-string interpolation
instead of raw concatenation.

* test: add unit tests for FiDevice.setConnectedTo

Tests cover all connection state types:
- ConnectedToUser with both names present
- ConnectedToUser with null lastName (the bug that caused TypeError)
- ConnectedToUser with null firstName
- ConnectedToUser with both names null
- ConnectedToUser with missing name keys entirely
- ConnectedToCellular with signal strength
- ConnectedToBase with base ID
- Unknown connection type returning None

---------

Co-authored-by: prestomation <dev@prestomation.local>
@ajacques
ajacques merged commit 54fb260 into tryfi:master Jun 27, 2026
3 checks passed
@ajacques

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

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.

2 participants