Skip to content

Decoder fails on unknown TLV tags in port 151 payloads #180

@JanickFischer

Description

@JanickFischer

Describe the bug
The TLV parser in pkg/common/helpers.go returns a hard error when it encounters a tag that isn't defined in the decoder's config:

return nil, fmt.Errorf("unknown tag %x", tag)

This means if the device firmware adds new config settings to port 151, the entire decode fails — even though the known fields are perfectly valid and the TLV format is inherently forward-compatible (each tag carries its own length).

Port 151 on the Tag XL is currently the only port using TLV-based parsing, but the bug is in the shared Decode function and would affect any future TLV-based ports as well.

To Reproduce
Steps to reproduce the behavior:

  1. Send a port 151 payload containing a tag not defined in the decoder (e.g. 4c0501ff020000 which contains an unknown tag 0xff)
  2. See error: unknown tag f

Expected behavior
Unknown tags should be skipped gracefully (advancing the index past their value using the length field) instead of causing the entire decode to fail. A warning log should be emitted so new tags are visible.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: any
  • Version any

Additional context
The fix is straightforward: Replace the hard error with a skip + warning:

if found { index += length } else { slog.Warn("skipping unknown tag", "tag", fmt.Sprintf("%x", tag), "length", length) index += length }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions