Skip to content

Add failing tests for #1632#1645

Draft
prompt-driven-github[bot] wants to merge 3 commits into
mainfrom
fix/issue-1632
Draft

Add failing tests for #1632#1645
prompt-driven-github[bot] wants to merge 3 commits into
mainfrom
fix/issue-1632

Conversation

@prompt-driven-github

Copy link
Copy Markdown
Contributor

Summary

Adds failing regression tests that detect the bug reported in #1632: long-running cloud checkup/fix jobs keep using the original (now-expired) GitHub App installation token for progress/state comments instead of reading the refreshed PDD_GH_TOKEN_FILE, causing HTTP 401: Bad credentials.

Test Files

  • tests/test_agentic_common.py — centralized helper tests + step/PR/final comment + state save/restore paths (incl. 3 folded-in reproduction tests)
  • tests/test_ci_validation.pygh chokepoint (_run_command) routes through the refreshed token; local git still works
  • tests/test_agentic_change_orchestrator.py_fetch_issue_updated_at / _check_existing_pr gh calls

Prompt Files (source-of-truth fixes from Step 7)

  • pdd/prompts/agentic_common_python.prompt — requires _github_token_from_env() / _gh_subprocess_env() and env= injection on every authenticated gh subprocess
  • pdd/prompts/ci_validation_python.prompt
  • pdd/prompts/agentic_change_orchestrator_python.prompt

What This PR Contains

  • 14 behavioral failing tests reproducing the reported bug at the exact subprocess boundary
  • Prompt spec fixes that require fresh-token injection
  • Tests are verified to fail on current code (14 failed) and will pass once the fix is implemented

Root Cause

GitHub App installation tokens expire 1 hour after creation. Every authenticated gh/gh api/gh pr/gh issue subprocess in agentic_common.py (11 sites), agentic_change_orchestrator.py, and ci_validation.py::_run_command is spawned via subprocess.run(cmd, ...) with no env=, so it inherits the frozen launch-time os.environ token. After the 1-hour TTL these calls replay the stale ambient GH_TOKEN and 401 instead of reading the refreshed PDD_GH_TOKEN_FILE.

Next Steps

  1. Add _github_token_from_env() (prefer freshly-read PDD_GH_TOKEN_FILEGH_TOKENGITHUB_TOKENPDD_GITHUB_TOKEN) and _gh_subprocess_env() to pdd/agentic_common.py
  2. Thread env=_gh_subprocess_env() through all authenticated gh subprocesses across the 3 files
  3. Verify the 14 -k 1632 tests pass
  4. Run full test suite for regressions
  5. Mark PR as ready for review

Fixes #1632


Generated by PDD agentic bug workflow

Long-running cloud checkup/fix jobs keep posting GitHub progress/state
comments with the original GitHub App installation token after its 1-hour
expiry, returning HTTP 401 instead of reading the refreshed PDD_GH_TOKEN_FILE.
Every authenticated gh/gh api/gh pr/gh issue subprocess in agentic_common.py,
agentic_change_orchestrator.py and ci_validation.py is spawned with no env=,
so it inherits the frozen launch-time os.environ token.

Adds 14 behavioral regression tests proving a refreshed PDD_GH_TOKEN_FILE must
override a stale ambient GH_TOKEN for step/PR/final comments, state save/restore
sync, the ci_validation gh chokepoint, and change-orchestrator gh calls. Also
fixes the source-of-truth prompts to require fresh-token subprocess env
injection (_github_token_from_env/_gh_subprocess_env).

Tests fail on current code and will pass once the fix is implemented.

Fixes #1632

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checkup progress comments can keep using expired GitHub token during long cloud runs

1 participant