Skip to content

Allow unknown TLVs to pass through#224

Merged
emontnemery merged 5 commits intohome-assistant-libs:mainfrom
puddly:puddly/fix-meshcop-tlvs
Feb 3, 2026
Merged

Allow unknown TLVs to pass through#224
emontnemery merged 5 commits intohome-assistant-libs:mainfrom
puddly:puddly/fix-meshcop-tlvs

Conversation

@puddly
Copy link
Contributor

@puddly puddly commented Jan 29, 2026

Unknown TLVs should not be a hard parsing failure (in this case we were missing DURATION = 23), they are inevitable and the TLV structure allows them to be passed through and re-serialized untouched.

#209 will add the missing TLVs.

@puddly puddly changed the title Update meshcop TLVs and allow unknown TLVs to pass through Allow unknown TLVs to pass through Jan 29, 2026
@puddly
Copy link
Contributor Author

puddly commented Jan 30, 2026

This will also fix home-assistant/addons#4357

@agners agners requested a review from emontnemery January 30, 2026 16:56
Copy link
Contributor

@agners agners left a comment

Choose a reason for hiding this comment

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

Seems sensible to me!

@TheZoker
Copy link

TheZoker commented Feb 1, 2026

Would be amazing, if this can be merged/releases rather quickly since my boarder router does not work because of this issue and I can't use my matter via thread devices. Thanks!

@lkm
Copy link

lkm commented Feb 1, 2026

I've tried to patch my live installation with this and run into this exception instead.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 762, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/otbr/__init__.py", line 73, in async_setup_entry
    await update_issues(hass, otbrdata, dataset_tlvs)
  File "/usr/src/homeassistant/homeassistant/components/otbr/util.py", line 268, in update_issues
    _warn_on_default_network_settings(hass, otbrdata, dataset_tlvs)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/otbr/util.py", line 224, in _warn_on_default_network_settings
    dataset = tlv_parser.parse_tlv(dataset_tlvs.hex())
  File "/usr/local/lib/python3.13/site-packages/python_otbr_api/tlv_parser.py", line 187, in parse_tlv
    raise TLVError(f"expected {_len} bytes for tag {tag!r}, got {length - pos}")
python_otbr_api.tlv_parser.TLVError: expected 162 bytes for tag 61, got 6

UPDATE: I think this has to do with the fact that my OTBR docker instance had dropped it's active dataset entirely and reconfiguring via the UI didn't reapply it, however, manually setting the active dataset to the backed up value via ot-ctl did fix it.

Copy link
Collaborator

@emontnemery emontnemery Feb 3, 2026

Choose a reason for hiding this comment

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

Why do we modify the existing tests instead of adding new tests?
Also, is all the the new code covered by tests?

Edit: The only added code not covered is the handling of duplicated tags


# Once we have the value, we can log a warning about the unknown TLV
if not isinstance(tag, MeshcopTLVType):
_LOGGER.warning("unknown TLV type %d=%r", raw_tag, val)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering the point of the PR it to let unknown tags pass through, I'm not sure we should log a warning? I'd suggest to lower severity to debug since this shouldn't matter to the user.

@emontnemery
Copy link
Collaborator

I discussed this with @puddly and we decided to merge this PR as is and improve the tests in a follow-up to ensure this PR is included in Home Assistant Core 2026.2.0 which is released tomorrow.

@emontnemery emontnemery merged commit d1c8d3d into home-assistant-libs:main Feb 3, 2026
1 check passed
emontnemery added a commit that referenced this pull request Feb 3, 2026
* Format code

* Fix typing
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.

5 participants