Skip to content

fix parsing of messages with no zones#1625

Merged
panentheos merged 1 commit intomasterfrom
bhw/parse
Apr 17, 2026
Merged

fix parsing of messages with no zones#1625
panentheos merged 1 commit intomasterfrom
bhw/parse

Conversation

@panentheos
Copy link
Copy Markdown
Collaborator

Summary of changes

This fixes a parsing error when receiving messages with an empty zone list, which happens sometimes because of some sign configs. After the message is parsed this way, the downstream logic will correctly end up treating it as a no-op.

@panentheos panentheos requested a review from a team as a code owner April 17, 2026 13:20
zone ->
{String.split(zone, "-") |> List.first(),
MapSet.new(zones, &(String.split(&1, "-") |> List.last()))}
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My clever-pattern-matching neuron is activating:

defp decode_zones([]), do: {nil, MapSet.new()}

defp decode_zones([first | _] = zones) do
  # ...
end

Opinions on whether this is more readable may vary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Definitely would have done that, but the parameter is a MapSet, which is less amenable to matching.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ohhhhhh. I guess I assumed it was a list since you were explicitly picking out the "first" item, not realizing this was just a way to pick a single arbitrary item out of a set.

@panentheos panentheos merged commit c04cc6d into master Apr 17, 2026
7 checks passed
@panentheos panentheos deleted the bhw/parse branch April 17, 2026 14:01
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