Skip to content

fix: keep circuit and name paired when parsing the find output - #571

Open
joltcoke wants to merge 1 commit into
rg-engineering:masterfrom
joltcoke:fix-findparams-pr
Open

joltcoke wants to merge 1 commit into
rg-engineering:masterfrom
joltcoke:fix-findparams-pr

Conversation

@joltcoke

Copy link
Copy Markdown

Problem

FindParams and ebusd_find split the telnet answer on line breaks and commas:

const datas = str.split(/[\r?\n,]+/);
const names = datas[i].split(",");

The first split already flattens ehp,Name\nehp,Other into single tokens, so the
following split(",") finds nothing left and names[1] is always undefined.

  • FindParams returns every entry with name undefined and the message names
    sitting in the circuit field, plus one stray entry holding the bare circuit.
  • ebusd_find passes undefined as both name and comment to UpdateDP.

The admin compensates by reading item.circuit, which is why the polled datapoint
list still looks right today — that is what kept this hidden.

The character class also contains ? as a literal, so a message name containing
one gets torn apart as well.

Change

Split on line breaks only. That restores the pairing, and the existing empty-entry
filter starts working too — it compared undefined to "", which is false in JS.

In ebusd_find the comment is now taken as the last field instead of the third
one: ebusd quotes it when it contains a comma, and 27 of 354 lines in my
configuration do.

QueriedDPSettings.tsx switches to item.name, which is only correct once the
backend fills it.

Verified against a running ebusd

before after
find -c ehp -F circuit,name, 184 lines 148 entries, name populated 147 entries, name populated 147×
stray entry with the bare circuit yes gone
ebusd_findUpdateDP name and comment undefined 347 calls, all three arguments populated
comments containing a comma truncated 27 complete, quotes stripped

Note on the build output

This PR touches sources only. Rebuilding here rewrites admin/index_m.html and
src-admin/build/index.html almost entirely because the committed files use CRLF
while the build writes LF — 148 lines of churn for one changed asset reference.
Happy to add the build output if you prefer it in the same PR.

FindParams and ebusd_find split the telnet answer on line breaks AND commas:

    const datas = str.split(/[\r?\n,]+/);
    const names = datas[i].split(",");

The first split already flattens "ehp,Name\nehp,Other" into single tokens, so
the following split(",") finds nothing left and names[1] is always undefined.
FindParams therefore returned every entry with name undefined and the message
names sitting in the circuit field, plus one stray entry holding the bare
circuit. ebusd_find passed undefined as both name and comment to UpdateDP.
The admin compensated by reading item.circuit, which is why the polled
datapoint list still looked right.

The character class also contained "?" as a literal, so a message name
containing one got torn apart as well.

Splitting on line breaks only restores the pairing. The empty-entry filter
starts working too - it compared undefined to "", which is false in JS.

In ebusd_find the comment is now taken as the last field instead of the third
one: ebusd quotes it when it contains a comma, and 27 of 354 lines do.

Verified against ebusd on a real installation: 184 lines for "find -c ehp -F
circuit,name" now yield 147 unique {circuit, name} pairs, all names populated,
no stray entry. For "find -F circuit,name,comment" all 347 datapoints get
circuit, name and the full comment.
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.

1 participant