Skip to content

fix(spawn): convert team config paths for readfile() via agmsg_sql_readfile_path#396

Open
chemica-tan wants to merge 1 commit into
fujibee:mainfrom
chemica-tan:fix/spawn-readfile-native-windows-path
Open

fix(spawn): convert team config paths for readfile() via agmsg_sql_readfile_path#396
chemica-tan wants to merge 1 commit into
fujibee:mainfrom
chemica-tan:fix/spawn-readfile-native-windows-path

Conversation

@chemica-tan

Copy link
Copy Markdown

Summary

resolve_team in spawn.sh is the only readfile() caller that passes a raw sed-escaped path into SQL. Every other caller (join.sh, whoami.sh, identities.sh, api.sh, resolve-project.sh) already goes through agmsg_sql_readfile_path, which cygpath-converts the path on Windows and SQL-escapes it. This PR aligns spawn.sh with them (1 line) and adds a regression test.

Symptom / minimal reproduction

Environment: Windows, Git Bash, a native Windows sqlite3.exe first on PATH (e.g. the WinGet build — sqlite3 3.53.3).

A native sqlite3.exe cannot readfile() a POSIX-form path (/tmp/..., /c/...): it returns NULL, the JSON probe yields no rows, and spawn dies with no team is registered even though join.sh just succeeded:

$ ./scripts/join.sh myteam alice claude-code "$PWD"
Joined team myteam as alice
$ ./scripts/spawn.sh claude-code bob --project "$PWD"
spawn: no team is registered ...

In normal use the bug is masked because registrations usually hold C:/-form project paths — but the bats suite runs under a POSIX-form $TMPDIR, so on such a machine every join→spawn test fails (38 failures for us). With this fix the suite is green again (remaining failures on our machine are unrelated, pre-existing environment issues).

  • agmsg version: v1.1.7 (also reproduced on v1.1.6)
  • host agent: Claude Code (found while running the test suite; diagnosis cross-checked by a Codex reviewer)

Change

  • scripts/spawn.sh: cfg_sql=$(printf '%s' "$config_file" | sed "s/'/''/g")cfg_sql=$(agmsg_sql_readfile_path "$config_file") (the variable feeds both queries in the loop, so one line covers both)
  • tests/test_spawn.bats: source-level regression assert. No portable runtime probe exists — it would need a native sqlite3 plus a POSIX-form tmpdir — so the test pins the helper usage directly, with a comment explaining why.

The single-quote behaviour is preserved: the helper SQL-escapes exactly like the old sed, and spawn: team resolution survives a single quote in the project path still passes.

Tests

$ bats tests/test_spawn.bats -f "team"
1..6
ok 1-6 (including the new regression test)

🤖 Generated with Claude Code

https://claude.ai/code/session_013Hh8w1h5CJJH77a6N4gwN2

…adfile_path

resolve_team was the only readfile() caller that passed a raw sed-escaped
path into SQL. With a native Windows sqlite3.exe first on PATH (e.g. the
WinGet build), readfile() on a POSIX-form path returns NULL, the JSON
probe yields no rows, and spawn dies with 'no team is registered' even
though join succeeded. Every other caller (join.sh, whoami.sh,
identities.sh, api.sh, resolve-project.sh) already uses the helper,
which cygpath-converts and SQL-escapes; align spawn.sh with them.

Real-world impact is masked in normal use because registrations hold
C:/-form project paths, but the test suite runs under a POSIX-form
$TMPDIR, so on such a machine every join->spawn test fails. Adds a
source-level regression assert (no portable runtime probe exists: it
would need a native sqlite3 plus a POSIX-form tmpdir).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Hh8w1h5CJJH77a6N4gwN2
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.

1 participant