spawn_test: non-string env values raise in the tester thread — Test launch / Test all stuck disabled #34
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found in audit of
main@06326e5.spawn_test()(bcc_core.py~L1584) buildsmerged_env = {**os.environ, "PATH": augmented_path()}thenmerged_env.update(data.get("env") or {})and passes it tosubprocess.Popen. If a server'senvcontains a non-string value — trivially reachable by pasting JSON like"env": {"PORT": 8080}and saving without ever opening the editor (the KeyValueTable str()-casts on load, but paste/import doesn't round-trip through it) —PopenraisesTypeError, which is not in theexcept (FileNotFoundError, OSError)clause.The exception escapes
SpawnTester.run()/ the Test-all worker:doneis never emitted, so:Args are already str-cast (
[str(a) for a in …]); env is the gap.argscontaining non-str is handled;commandnon-str is.strip()ed — a non-strcommand(e.g. number) would also raiseAttributeErrorbefore that ((data.get("command") or "").strip()breaks on int → actuallyor ""passes the int through;.strip()→ AttributeError). Same escape path.Proposed fix
spawn_test: coerce env keys/values withstr()when merging; coercecommandviastr(data.get("command") or "").strip().spawn_test(orSpawnTester.run/ the test-all worker) so any unexpected exception returns/emits an{"outcome": "crashed", "detail": repr(e)}-style result instead of dying silently — the UI must always get a result.Acceptance
spawn_test({"command": sys.executable, "args": ["-c", "pass"], "env": {"PORT": 8080}})returns a result dict (no exception), and the env value is passed as"8080".