fix(spawn): convert team config paths for readfile() via agmsg_sql_readfile_path#396
Open
chemica-tan wants to merge 1 commit into
Open
Conversation
…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
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.
Summary
resolve_teaminspawn.shis the onlyreadfile()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 throughagmsg_sql_readfile_path, which cygpath-converts the path on Windows and SQL-escapes it. This PR alignsspawn.shwith 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 withno team is registeredeven thoughjoin.shjust succeeded: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).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 pathstill passes.Tests
🤖 Generated with Claude Code
https://claude.ai/code/session_013Hh8w1h5CJJH77a6N4gwN2