Repository navigation
fix(parser,prereq): jq is required — fallback parser corrupts gist envelopes without it (continuum's diagnosis) - #162
Merged
Conversation
…rrupts gist envelopes without it Bug found by continuum-b69f Win→Mac e2e 2026-04-27 (forensics in cross-Mac/Windows coord gist): continuum's airc connect from Windows Git Bash succeeded with "Connected to '\"invite\":\"authenticator-fd63'" — JSON envelope syntax leaked into the displayed peer name. Worse: - room_name file never written to disk - subsequent airc msg stored locally with from:"unknown" - broadcast never landed in mac host's messages.jsonl Two bugs from one root cause: **jq missing on Windows Git Bash.** ## Root cause cmd_connect's gist resolver has two paths: 1. JSON envelope parse via jq — sets `resolved` (invite string) AND `resolved_room_name` from `.name` field. 2. Legacy raw-string fallback — bare grep for the first `@.*@` line. When jq is absent on PATH (the default state on Git Bash), path 1 short-circuits silently. Path 2 grabs the whole quoted JSON line including the `"invite":"` key prefix. The downstream @-split (which extracts name@user@host:port) then captures the JSON-key fragment as the peer name. Worse: `resolved_room_name` is ONLY set inside path 1's room-case branch. Path 2 leaves it empty. Hence the `if [ -n "$resolved_room_name" ]; then echo ... > room_name` write at line 2495 never fires. Joiner connects "successfully" but doesn't know what room they're in. Subsequent msg sends queue/ship without room context; host filters them out. ## Fix (three layers) ### Layer 1: jq is now a required prereq (install.sh + install.ps1 + airc doctor) - install.sh: added `jq` to the prereq install loop. pkgname_for maps `jq` → `jqlang.jq` on winget, bare `jq` on brew/apt/dnf/pacman/apk. - install.ps1: new `Install-IfMissing -Name 'jq' -WingetId 'jqlang.jq'` line. - airc doctor: new probe `_doctor_probe "jq" "Gist envelope parser (rooms, addresses)"` flags missing jq with the same install hint shape as other prereqs. ### Layer 2: legacy fallback now strips JSON-key prefix The grep-based fallback can still be reached on minimal environments that genuinely don't have jq (busybox+nothing, weird CI). Pre-fix it captured `"invite":"authenticator-fd63@...` verbatim. Post-fix: `sed -E 's/^[^a-zA-Z]+//'` strips leading non-letter characters before the @-split runs. JSON quotes, key syntax, leading whitespace all stripped uniformly. ### Layer 3: legacy fallback now extracts room name When jq is missing, the fallback also walks the raw_content for `"name": "..."` and captures the value into `resolved_room_name`. Same JSON envelope shape as the jq path; sed-only so it works without any JSON parser. Empty for legacy gists (no envelope) — matches pre-existing behavior on those. ## Why three layers Layer 1 (jq required) is the canonical fix — every install going forward has jq, the JSON path always works. Layers 2+3 are defense in depth: any environment that escapes layer 1 (older airc installs, manual installs, distros where jq install fails) won't silently corrupt — fallback now produces a correct peer name AND the right room_name file. ## Test posture Mac doctor with PR live: all probes [ok] including new jq. ``` [ok] git [ok] gh [ok] gh authenticated [ok] openssl [ok] ssh [ok] ssh-keygen [ok] python3 [ok] jq [ok] sshd (Remote Login enabled) [ok] tailscale (optional) -- daemon up ``` Mac regression: - part_persists: 8/8 - list: 4/4 - general_sidecar_default: 12/12 - platform_adapters: 11/11 ## Out of scope continuum-b69f's UTF-8 → Latin-1 double-decode on `→` is a separate encoding bug in the bash → python3 → jq pipeline. File for follow-up; this PR is JSON-key-leak + jq-as-prereq.
joelteply
added a commit
that referenced
this pull request
Apr 27, 2026
…nd-to-end (#177) fix(msys): export MSYS2_ARG_CONV_EXCL at airc startup — last layer of cross-machine fix (continuum's catch + verify) continuum-b69f's diagnosis 2026-04-27: even with PR #174 + #176's argparse `--flags`, MSYS Git Bash on Windows translates argv VALUES that look like Unix-rooted paths when bash invokes a Windows-native binary. So `--host-airc-home /Users/joelteply/.airc` arrived at python.exe as `--host-airc-home C:/Program Files/Git/Users/joelteply/.airc`, the joiner cached the corrupted path, the SSH command later sent it to a real Unix host that had no such file. Silent broadcast failure. ## Fix ```bash export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}" ``` Set once at airc startup, exported, every airc_core invocation inherits the same translation policy. Targeted prefix list covers macOS / Linux / root home prefixes without breaking `/tmp/` or `/c/` paths (which DO need translation for `--config "$CONFIG"` where $CONFIG is on the local Windows filesystem). Honors a user override via the `${...:-...}` default-fallback. ## End-to-end verification continuum-b69f shipped a test broadcast from Windows after their local patch: > WORKING TEST: Windows-Mac airc msg via continuum-msyspatch with > targeted MSYS exclude. should land! Verified live in MY host's messages.jsonl on Mac: ``` {"from":"continuum-msyspatch","to":"all","ts":"2026-04-27T23:30:13Z", "msg":"WORKING TEST: Windows-Mac airc msg via continuum-msyspatch with targeted MSYS exclude. should land!","sig":"..."} ``` **Cross-machine Mac↔Windows airc end-to-end working.** This was the last bug in the chain that started at PR #153 (Microsoft Store python3 stub). ## Test posture (Mac, where the env var is a no-op) - tabs 19/19, identity 19/19, whois 5/5, part_persists 8/8, list 4/4, general_sidecar_default 12/12, kick 12/12, events 5/5, platform_adapters 11/11, whois_cross_scope 6/6 ## Today's full chain of cross-machine fixes #153 → #154 → #155 → #156 → #157 → #158 → #159 → #160 → #162 → #164 → #165 → #166 → ... → #176 → this. 27+ PRs to ship a working cross-machine airc on Windows. Every step revealed a new layer.
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.
Bug (continuum-b69f Win→Mac e2e 2026-04-27)
Windows airc connect "succeeded" but:
Root cause
`cmd_connect`'s gist resolver has two paths. The JSON-envelope parse path is gated on `command -v jq`. Windows Git Bash ships without jq by default. Falls through to grep-based fallback that captures the JSON `"invite":"...` key prefix into the parsed invite, AND never sets `resolved_room_name`. Hence both the corrupt peer name AND the missing room_name file.
Three-layer fix
1. jq is now a required prereq. install.sh, install.ps1, airc doctor — all updated. winget id `jqlang.jq`; brew/apt/dnf/pacman/apk all use bare `jq`.
2. Legacy fallback strips JSON-key prefix. `sed -E 's/^[^a-zA-Z]+//'` before @-split. Defense in depth for any minimal environment that escapes layer 1.
3. Legacy fallback extracts room name. Walks raw_content for `"name": "..."` regex and captures the value when jq is absent. Same envelope shape; works without any JSON parser.
Test posture
Doctor live on this Mac shows new `[ok] jq`. Mac regression all green (part_persists 8/8, list 4/4, general_sidecar_default 12/12, platform_adapters 11/11).