Repository navigation
fix(cli): repair --from-json crash, empty-2xx parse, login identity & hang - #1
Merged
Merged
Conversation
… hang Four user-reported bugs in the shipped (node-target) binary: - C1: --from-json read files via Bun.file(), undefined in the node binary, crashing every call with "Bun is not defined". Extracted a shared readJsonObject() using node:fs/promises and removed the 7 duplicated copies across options/goals/events/collections add & edit. - C2: option-creation returns 201 with no body; openapi-fetch's JSON parser threw "Failed to parse JSON", which bypassed the error check and reported a server-side success as failure -> silent duplicates on retry. The client middleware now normalizes empty 2xx bodies to undefined data. - C3: whoami showed <unknown@local> because login never fetched identity. Both login flows now call GET /v1/me via a shared fetchIdentity() helper. - C4: `mna login` hung after browser approval because a keep-alive socket kept the loopback server (and event loop) alive. Send Connection: close and call closeAllConnections() so the CLI exits on its own. Adds tests for the JSON util and the empty-201 client behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes four user-reported bugs in the shipped (node-target) binary.
C1 —
--from-jsoncrashed with "Bun is not defined" · HighreadJsonBodyread files viaBun.file(), which is undefined in the node binary, so every--from-jsoncall died before sending a request. The bug existed in 7 commands, not justoptions(goals,events,collectionsadd/edit too).Fix: shared
readJsonObject()usingnode:fs/promises, replacing the 7 duplicated copies.C2 — successful create reported as failure → silent duplicates · High
Option creation returns
201with no body; openapi-fetch's JSON parser threw "Failed to parse JSON", which bypassed theerrorcheck and surfaced a server-side success as a CLI failure. Retrying created duplicates.Fix: the client middleware normalizes empty 2xx bodies to
undefineddata.C3 —
whoamishowed<unknown@local>· LowLogin never fetched identity. Both login flows now call
GET /v1/mevia a sharedfetchIdentity()helper.C4 —
mna loginhung after browser approvalA keep-alive socket kept the loopback server (and event loop) alive. Now sends
Connection: closeand callscloseAllConnections()so the CLI exits on its own.Tests
Adds coverage for the JSON util (incl. the no-Bun path) and the empty-
201client behavior. typecheck + lint + 22 tests green.🤖 Generated with Claude Code