fix(pr_agent/servers/bitbucket_app.py): building the secret provider per process - #2736
Conversation
…ering the per-process secret provider
PR Summary by QodoMake Bitbucket secret provider fork-safe under gunicorn preload_app
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
…alidated at startup
…ering the startup validation
|
Code review by qodo was updated up to the latest commit 4e4054d |
…idating through an import rather than the source text
|
Code review by qodo was updated up to the latest commit 1339c3b |
Closes #2735.
Description
bitbucket_app.py:30constructs the secret provider at module import, andgunicorn_config.py:160setspreload_app = True, so the client is created in the master and inherited by every forked worker.Root cause
This is the exact hazard
gitlab_webhook.py:36-48already fixes and documents:bitbucket_app.pyhad 0 references to a fork-safe accessor — the fix was applied to GitLab only.The fix
Replace the module-level
secret_provider = ...withget_fork_safe_secret_provider(), apid-keyed accessor mirroring
gitlab_webhook.get_fork_safe_secret_provider(). Both call sites(
handle_github_webhooks,handle_installed_webhooks) go through it.Behaviour change
Files changed
Testing
New regression coverage in
tests/unittest/test_bitbucket_fork_safe_secret_provider.py— 4 tests, each written to failwithout the fix:
Proven to be a genuine regression test: with every changed
pr_agent/file reverted to itsorigin/mainversion and the new test file left in place, the suite fails. It only passeswith the fix applied.
Full pipeline, reproduced locally exactly as
.github/workflows/build-and-test.yamlruns it:on
python:3.12.13-slim— no failures.Also checked:
pytest tests/unittest— no new failures vsmainruff— no new findings vsmain;isort— clean on every file touchedRisk / compatibility
Deployments without
CONFIG.SECRET_PROVIDERstill getNone, exactly as before. The accessor adds one dict lookup per webhook.Checklist