Skip to content

page-usage-tree 0.1.7: a bracketed IPv6 MAGPIE_ADDR in uppercase hex stays a gateway candidate - #2055

Merged
yetone merged 1 commit into
magpie-community:mainfrom
sarankumar1325:fix/page-usage-tree-uppercase-ipv6
Dec 5, 2026
Merged

yetone merged 1 commit into
magpie-community:mainfrom
sarankumar1325:fix/page-usage-tree-uppercase-ipv6

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes #2054.

0.1.6 (#2045) added a bracketed-IPv6 branch to the MAGPIE_ADDR pattern in lib/gateway.mjs, but the character class is [0-9a-f:.], so an address written in uppercase hex such as [FE80::1]:3425 didn't match and was dropped. The first candidate fell back to http://127.0.0.1:3425.

Change

  • lib/gateway.mjs: add the i flag to the host:port / [v6]:port pattern. The hostname branch ([\w.-]+) already accepts either case, so only the IPv6 branch changes behaviour.
  • test/gateway.test.mjs: new test, MAGPIE_ADDR=[FE80::1]:3425 must stay http://[FE80::1]:3425. It fails on 0.1.6 (got http://127.0.0.1:3425) and passes with the fix.
  • package.json: 0.1.6 → 0.1.7.

Checks

  • node --test test/*.test.mjs in packages/page-usage-tree: 77 pass, 0 fail
  • HOME=$(mktemp -d) bun test in packages/page-usage-tree: 70 pass, 1 skip, 0 fail
  • bun scripts/check.mjs: clean

The chat package's equivalent (#2051) isn't touched here.

This change was prepared with help from an AI assistant (Grok Bot). I reviewed it and ran the tests above.

…stays a gateway candidate

The bracketed-IPv6 pattern added in 0.1.6 matched only lowercase hex, so
[FE80::1]:3425 was dropped. Match it case-insensitively and cover it with
a test that fails on 0.1.6.

Fixes magpie-community#2054

Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
@yetone

yetone commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Shipped in page-usage-tree 0.1.7 (382e2c9). It's served from the dist branch (tgz/magpie-community-page-usage-tree-0.1.7.tgz, checked: its lib/gateway.mjs has the i flag). magpie picks it up on its next plugin update. The publish run shows red only for middleware-system-prompt 0.1.1 and middleware-think-tags 0.1.2, which npm turns away with E404; this package isn't affected. The same case-sensitive pattern in page-usage-board is #2057.

yetone added a commit that referenced this pull request Dec 5, 2026
… stays the gateway (#2057)

Fixes #2057, the sibling of #2054 that page-usage-tree 0.1.7 fixed (#2055).
server.mjs's gatewayCandidates matched MAGPIE_ADDR with
/^(\[[0-9a-f:.]+\]|[\w.-]+):\d+$/ and no i flag, so `[FE80::1]:3425` was
dropped and the board asked http://127.0.0.1:3425. The pattern now has the
i flag; the hostname branch already took either case.

New test: MAGPIE_ADDR=[::FFFF:7F00:1]:<port> (127.0.0.1 written as an
IPv4-mapped IPv6 address in uppercase hex, so nothing leaves the machine)
is logged as gateway=http://[::FFFF:7F00:1]:<port>, not the 3425 default,
and where the mapped address is reachable /api/overview is answered by the
fake gateway on 127.0.0.1. page-usage-board 0.2.0 -> 0.2.1.

Run at tree 2211cee (both commits on origin/main 382e2c9), on Linux
(WSL2 magpie-desktop, Bun 1.4.2, Node 22, HOME=$(mktemp -d) in /tmp):
- HOME=$(mktemp -d) bun test (root): 11302 pass, 47 skip, 0 fail, 758 files
- bun test packages/chat: 87 pass, 1 skip, 0 fail
- bun test packages/page-usage-board: 58 pass, 0 fail
- node --test test/*.test.mjs (page-usage-board): 58 pass, 0 fail
- bun scripts/check.mjs: ok
- bun scripts/bumped.mjs origin/main (HQ, git only): ok
- Red on the old code: chat's new test against origin/main's
  lib/gateway.mjs fails at [::1] (got http://127.0.0.1:3425), and with
  the new pattern minus the i flag at [FE80::1]; the board's new test
  against origin/main's server.mjs fails (gateway=127.0.0.1:3425 logged),
  the [::1] test beside it stays green.
- The IPv4-mapped address answers on WSL Linux, so the board test's
  request branch ran there.

Not tried: a real magpie listening on [::1], macOS and Windows (the
board's request branch is skipped where the mapped address doesn't
answer). Other MAGPIE_ADDR readers were checked and keep a bracketed
or uppercase address: page-usage-tree, page-harnessweight (i flag
already), page-model-quota (URL parse), window-warmup, fingerprint
(passed through), agy-cli (bracket-aware, loopback only), agent-console
(port only).
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.

page-usage-tree: an uppercase bracketed IPv6 MAGPIE_ADDR ([FE80::1]:3425) is still dropped

2 participants