:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(hogli): pin docker compose project name to posthog (#70606)
Phil Haack38dc94180afe
diff --git a/tools/hogli-commands/hogli_commands/devenv/generator.py b/tools/hogli-commands/hogli_commands/devenv/generator.pyindex 59f13e8512c5..b795141c7fcb 100644--- a/tools/hogli-commands/hogli_commands/devenv/generator.py+++ b/tools/hogli-commands/hogli_commands/devenv/generator.py@@ -47,7 +47,10 @@ class DevenvConfig(BaseModel):def _get_docker_compose_base() -> str:- return "docker compose -f docker-compose.dev.yml -f docker-compose.profiles.yml"+ # Pin the project name so worktrees share one dev stack instead of each+ # defaulting to its own directory name.+ project_name = os.environ.get("COMPOSE_PROJECT_NAME") or "posthog"+ return f"docker compose -p {shlex.quote(project_name)} -f docker-compose.dev.yml -f docker-compose.profiles.yml"def build_docker_compose_command(profiles: list[str], action: str = "up -d") -> str:diff --git a/tools/hogli-commands/hogli_commands/tests/test_devenv.py b/tools/hogli-commands/hogli_commands/tests/test_devenv.pyindex 7978fb6973d6..ca52c9f27069 100644--- a/tools/hogli-commands/hogli_commands/tests/test_devenv.py+++ b/tools/hogli-commands/hogli_commands/tests/test_devenv.py@@ -14,7 +14,13 @@ import pytestfrom unittest import mockimport yaml-from hogli_commands.devenv.generator import DevenvConfig, MprocsConfig, MprocsGenerator, load_devenv_config+from hogli_commands.devenv.generator import (+ DevenvConfig,+ MprocsConfig,+ MprocsGenerator,+ build_docker_compose_command,+ load_devenv_config,+)from hogli_commands.devenv.registry import ProcessRegistry, create_mprocs_registryfrom hogli_commands.devenv.resolver import Capability, Intent, IntentMap, IntentResolver, load_intent_mapfrom hogli_commands.devenv.wizard import _parse_exclude_input@@ -440,6 +446,40 @@ class TestDockerProfiles:assert "etcd" in result.docker_profiles+class TestDockerComposeProjectName:+ """Test project-name selection in the generated docker compose command."""++ def test_defaults_to_posthog_when_unset(self, monkeypatch: Any) -> None:+ monkeypatch.delenv("COMPOSE_PROJECT_NAME", raising=False)++ cmd = build_docker_compose_command([])++ assert "-p posthog " in cmd++ def test_defaults_to_posthog_when_empty(self, monkeypatch: Any) -> None:+ monkeypatch.setenv("COMPOSE_PROJECT_NAME", "")++ cmd = build_docker_compose_command([])++ assert "-p posthog " in cmd++ @parameterized.expand(+ [+ ("plain name", "posthog-worktree", "posthog-worktree"),+ ("value with a space", "posthog dev", "posthog dev"),+ ("value with shell metacharacters", "posthog; rm -rf /", "posthog; rm -rf /"),+ ]+ )+ def test_project_name_from_env_is_shell_quoted(self, _name: str, env_value: str, expected_value: str) -> None:+ with mock.patch.dict(os.environ, {"COMPOSE_PROJECT_NAME": env_value}):+ cmd = build_docker_compose_command([])++ # The quoted project name must round-trip through shlex.split as a single token,+ # proving it can't be split into extra shell arguments or inject shell syntax.+ tokens = shlex.split(cmd)+ assert tokens[tokens.index("-p") + 1] == expected_value++class TestIntentMapLoading:"""Test intent map loading from YAML."""