PR stats parity tests can publish or overwrite real gists
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Read tools/pr-management/tests/stats/test_json_parity.py and the publication branch in tools/pr-management/src/pr_management/stats/dashboard.py. Run the parity tests and check how _run() builds dashboard arguments and how _install_stubs() handles authentication, publishing, and session state. Done means both tests pass without gh calls or session state changes, while reference commands still accept their supported arguments.
Written by the indexing model from the issue text.
Description
What's broken
The PR stats JSON parity tests call dashboard.main() with gist publishing enabled.
On a machine where gh is authenticated with the gist scope, running these unit tests can overwrite a real dashboard gist or create a secret gist in the developer's account, even though both tests pass.
Which layer
tools/pr-management/tests/stats/test_json_parity.py: _run() omits --no-publish, and _install_stubs() replaces only fetch functions.
The publication and session-state branch is in tools/pr-management/src/pr_management/stats/dashboard.py.
How to reproduce
Reproduced at upstream dadb315caa8b881fc1d2195bef03223dac25915a in an isolated Linux checkout with CPython 3.12.12 and workspace development dependencies.
Use a disposable checkout and this recording replacement; it makes no network requests and never delegates to real gh.
set -euo pipefail
stub_dir="$(mktemp -d)"
export H09_GH_LOG="$stub_dir/calls.log"
cat > "$stub_dir/gh" <<'SH'
#!/bin/sh
printf 'gh %s\n' "$*" >> "$H09_GH_LOG"
case "${1:-} ${2:-}" in
'auth status') printf "Token scopes: 'gist', 'read:org', 'repo'\n" ;;
'api -X') cat > /dev/null ;;
'gist create') printf '%s\n' 'https://gist.github.com/tester/0123456789abcdef0123456789abcdef' ;;
*) exit 98 ;;
esac
SH
chmod +x "$stub_dir/gh"
PATH="$stub_dir:$PATH" uv run --directory tools/pr-management --project . \
python -m pytest -q tests/stats/test_json_parity.py
cat "$H09_GH_LOG"
With the tracked legacy gist ID and no personal session state, both tests pass while the replacement records two gh auth status and two gist PATCH calls.
Without legacy or personal state, verified in a separate disposable run, the tests create a gist, PATCH it, and store the fake ID in .apache-magpie-local/session-state.json.
Expected vs actual
Expected: fixture-based tests compare JSON without authenticating with GitHub, publishing, or reading/writing gist session state.
Actual: the publication branch remains reachable outside the assertions.
The reviewed fix adds --no-publish to dashboard argv only and makes authentication, publication, and session-state entry points reject unexpected test access with pytest.fail.
The reference entry point rejects that flag, so it must not be added to shared argv unconditionally.
Surface area
One test file, 15 added lines; existing JSON assertions and production behavior are preserved.
Publication-wiring coverage, a stats-wide subprocess guard, tracked legacy-state cleanup, and explicit UTF-8 production HTML reads/writes are independent follow-ups.
Environment
Linux, CPython 3.12.12, pytest 9.1.1, non-root Docker validation with a recording gh replacement.
After the fix, both state scenarios pass with zero gh calls and no state changes; removing the opt-out or forcing any of the four entries ahead of it fails even inside except Exception.
Suggested labels: bug, family:pr-management, capability:stats.
Developed with Codex (GPT-6); the contributor has completed manual code review and approved the patch for upstream submission.
- Dominant language
- Python
- Stars
- 113
- Forks
- 95
- Avg merge
- 10h 48m
- Merged PRs (30d)
- 348
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/magpie
-
agent-guard: the +refspec force spelling bypasses the empty-rebase guardPossibly taken @liwenjie200543 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/magpie#1606 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-2 days Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Marketplace install fails with GitHub CopilotPossibly taken @opwvhk claimed this today. Openbug
Difficulty 3/5 Half a day Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Explore Claude Code mods across the skill familiesPossibly taken @Kaap10 claimed this 7 days ago. Opencapability:platform enhancement family:ci family:docs family:issue family:pairing family:pr-management family:release-management family:security family:setup family:tools family:utilities substrate:framework-dev
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/magpie#1497 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
vis.image() reports "Unsupported number of image channels: 224" for an HxWxC imagePossibly taken @piyush182004 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
fossasia/visdom#1997 · 3 comments ·
Maintainers usually reply within 6 days
-
Byse new domainOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Gujal00/ResolveURL#1525 ·
Maintainers usually reply within 1 day
-
Serialisation fails with pydantic 2.14: wrap serialisers pass SerializationInfo as index_keyPossibly taken @hugohills-regnosys claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
finos/rune-python-runtime#45 ·
-
[Bug]: LangGraph Store sync put bypasses namespace validationPossibly taken @ktz03 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
volcengine/OpenViking#6050 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hummingbot/condor#283 ·
Maintainers usually reply within 1 day