Skip to content

: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.

fix(ci): make two shard-order-dependent tests self-contained (#88241)

Tom Owers45b236fb34ac
diff --git a/posthog/management/commands/test/test_persons_dedup.py b/posthog/management/commands/test/test_persons_dedup.py
index e1b589ec25d6..c6b6bcc2cf5e 100644
--- a/posthog/management/commands/test/test_persons_dedup.py
+++ b/posthog/management/commands/test/test_persons_dedup.py
@@ -1008,12 +1008,22 @@ class TestPersonsDedupLogVisibility:
handler = _Collector()
original_level = parent.level
+ original_disabled = module_logger.disabled
+ original_global_disable = logging.root.manager.disable
parent.setLevel(logging.WARNING)
+ # Unrelated suites in the same worker reconfigure logging globally (dictConfig with
+ # disable_existing_loggers, logging.disable), which suppresses every record regardless
+ # of level. Clear both so the assertion isolates the one thing this test guards: the
+ # module's own level beating the parent clamp.
+ module_logger.disabled = False
+ logging.disable(logging.NOTSET)
module_logger.addHandler(handler)
try:
persons_dedup_command.logger.info("persons_dedup.log_visibility_probe", team_id=1)
finally:
module_logger.removeHandler(handler)
+ module_logger.disabled = original_disabled
+ logging.disable(original_global_disable)
parent.setLevel(original_level)
assert captured, "INFO records are dropped, so a production run would leave no log"
diff --git a/products/tasks/backend/temporal/process_task/tests/test_provision_sandbox.py b/products/tasks/backend/temporal/process_task/tests/test_provision_sandbox.py
index 81070e9a476b..6233e7abb2cd 100644
--- a/products/tasks/backend/temporal/process_task/tests/test_provision_sandbox.py
+++ b/products/tasks/backend/temporal/process_task/tests/test_provision_sandbox.py
@@ -452,7 +452,10 @@ def test_build_environment_variables_omits_otel_env_when_flag_disabled(_api, _jw
assert not any(key.startswith("POSTHOG_AGENT_OTEL_") for key in env)
-def test_build_environment_variables_forwards_run_context_to_token_minting():
+@patch(f"{_PROVISION}.get_git_identity_env_vars", return_value={})
+@patch(f"{_PROVISION}.get_sandbox_jwt_public_key", return_value="pub")
+@patch(f"{_PROVISION}.get_sandbox_api_url", return_value="https://api.example")
+def test_build_environment_variables_forwards_run_context_to_token_minting(_api, _jwt, _git):
"""The fresh-provisioning path must forward team, origin, stage, and internal
into token minting; a dropped kwarg silently degrades every fresh run to the
Python gateway."""