A position of 1e308 is accepted by both doors and opens a blank canvas #1421

Closed
opened 2026-11-11 04:27:04 +00:00 by jaylouisw · 0 comments
Owner

Two doors set a device's position: POST /api/topologies/:name/layout (the drag, and the tidy-up button) and Topology.fromJSON() on load. Both ask for { x, y } with two finite numbers — and the endpoint keeps its own copy of that sentence inline while the engine asks isPosition(). One rule, two implementations, the shape that has already drifted six times in this repository.

Both accept 1e308. Measured against a live server:

POST /api/topologies/k95/layout {"positions":{"sw1":{"x":1e308,"y":-1e308}}}  ->  200, stored
POST /api/topologies/k95/load  layout {"sw1":{"x":1e308,"y":1e308}}             ->  200, no loadIssues

1e308 is a finite number and it is not a place. In web/canvas.js fitView() the board's width is the largest x minus the smallest — Infinity for two such positions — so zoom clamps to its 0.25 floor, translate() is handed -1e308, and the canvas draws nothing. "Fit to view" computes the same arithmetic, so the board cannot be recovered from the UI at all. The lab is not lost; it cannot be seen, which for a person is the same thing. Reachable from an imported document, a hand-edited one, or an auto-layout script with a bug.

Two smaller holes at the same door:

  • {"positions": [..]}, {"positions": "abc"}, {} → 200 {"ok":true} and nothing happens: the same 200-that-lies shape as #1309.
  • an id that is not on the board is dropped in silence, so a client posting a layout for a device that was deleted a moment ago cannot tell.

What should be true

  1. one rule, in the engine: a position is two finite numbers inside the canvas's world (WORLD_LIMIT = 1e6 pixels from the origin — the largest lab the catalogue can build spans tens of thousands);
  2. both doors ask that rule, and a refusal names the reason (out of the world vs. not two numbers) and changes nothing;
  3. on load, a bad position is dropped and reported (E_LAYOUT_BAD_ENTRY), so the board still opens;
  4. positions that is not a map is 400; an unknown id comes back in ignored;
  5. fitView() checks its own result — if the centre of what it measured does not land in the viewport, the framing failed and the default view is the honest answer, which also covers documents written before the limit existed;
  6. and the property that makes the limit worth having, asserted against the real web/canvas.js: every position the doors accept is one the canvas can frame.
Two doors set a device's position: `POST /api/topologies/:name/layout` (the drag, and the tidy-up button) and `Topology.fromJSON()` on load. Both ask for `{ x, y }` with two **finite** numbers — and the endpoint keeps its own copy of that sentence inline while the engine asks `isPosition()`. One rule, two implementations, the shape that has already drifted six times in this repository. Both accept `1e308`. Measured against a live server: ``` POST /api/topologies/k95/layout {"positions":{"sw1":{"x":1e308,"y":-1e308}}} -> 200, stored POST /api/topologies/k95/load layout {"sw1":{"x":1e308,"y":1e308}} -> 200, no loadIssues ``` `1e308` is a finite number and it is not a place. In `web/canvas.js` `fitView()` the board's width is the largest x minus the smallest — `Infinity` for two such positions — so zoom clamps to its 0.25 floor, `translate()` is handed `-1e308`, and the canvas draws **nothing**. "Fit to view" computes the same arithmetic, so the board cannot be recovered from the UI at all. The lab is not lost; it cannot be seen, which for a person is the same thing. Reachable from an imported document, a hand-edited one, or an auto-layout script with a bug. Two smaller holes at the same door: - `{"positions": [..]}`, `{"positions": "abc"}`, `{}` → `200 {"ok":true}` and nothing happens: the same 200-that-lies shape as #1309. - an id that is not on the board is dropped in silence, so a client posting a layout for a device that was deleted a moment ago cannot tell. ### What should be true 1. one rule, in the engine: a position is two finite numbers inside the canvas's world (`WORLD_LIMIT = 1e6` pixels from the origin — the largest lab the catalogue can build spans tens of thousands); 2. both doors ask that rule, and a refusal names the reason (out of the world vs. not two numbers) and changes nothing; 3. on load, a bad position is dropped and reported (`E_LAYOUT_BAD_ENTRY`), so the board still opens; 4. `positions` that is not a map is `400`; an unknown id comes back in `ignored`; 5. `fitView()` checks its own result — if the centre of what it measured does not land in the viewport, the framing failed and the default view is the honest answer, which also covers documents written before the limit existed; 6. and the property that makes the limit worth having, asserted against the real `web/canvas.js`: **every position the doors accept is one the canvas can frame.**
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge#1421
No description provided.