A cable label is a field of the cable, so it survives the save (#1513) #1537
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1537
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/1115-1935"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1513
What was wrong.
link.label = "via 0-LR-FP1 keystone 2"read back on the liveLinkand was written by nothing:Link.serialize()had nolabel, soTopology.serialize()dropped it and the annotation was gone at the next save. A property that accepts a value and keeps it nowhere is worse than a missing field, because it looks as if it worked.What changed.
engine/link.js:labelis a field of theLink(constructor,serialize()). It is written only when a cable has one, so a lab saved before the field existed produces the same document it always did.labelProblem()/normaliseLabel()hold the rule in one place: a label is a string,null/""mean none, anything else is refused.engine/topology.js:connect()takesopts.labeland refuses a non-string withE_BAD_LABEL;fromJSON()restores it;cableProblem()reportsE_LINK_BAD_LABELfor a document that states a label the Link cannot hold; newsetLinkLabel().server/index.js:POST /linkspasseslabelthrough;PATCH /links/:linkIdapplies one (it used to answer 200 and change nothing), and a label-only PATCH no longer touches the length.docs/ARCHITECTURE.md:labeladded to the cable round-trip list and to the load-issue table.Tests.
test/link-roundtrip.test.js: a label survives save/reload and is in the document;connect()takes one; an unlabelled cable writes no key; a non-string is refused withE_BAD_LABELand explained asE_LINK_BAD_LABELwhen a document states one; over HTTP, a label comes back on the cable it made, a PATCH sets, keeps and clears one without disturbing the length, and a numeric label is refused with 409.Suite:
node scripts/syntax-check.jsall OK; fullnode scripts/run-tests.js251 suites, 9216 assertions, 0 failures.80583f0f575f9782bb1e5f9782bb1ea90000dc75