test(marketplace): isolate test_auto_detect_through_proxy from real network#759
Merged
danielmeppiel merged 2 commits intomainfrom Apr 19, 2026
Merged
Conversation
…etwork The test mocked the proxy fetch but did not pass an auth_resolver to _auto_detect_path. When the proxy mock returned None for the first candidate path, _fetch_file fell through to the GitHub Contents API and instantiated a real AuthResolver, making a live request to api.github.com. On shared macOS runners this hit GitHub's anonymous rate limit and produced 403 failures in unit CI. Pass a mock auth_resolver (try_with_fallback returns None) so the fallback path is exercised hermetically and probing continues to the next candidate, which the proxy mock satisfies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates a flaky unit test to avoid unintended real GitHub network calls during proxy auto-detection, preventing intermittent CI failures due to anonymous rate limits.
Changes:
- Inject a mocked
auth_resolverintotest_auto_detect_through_proxyto prevent_fetch_filefrom instantiating a realAuthResolverand callingapi.github.com. - Add a changelog entry documenting the CI flake fix.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/marketplace/test_marketplace_client.py | Passes a mock auth_resolver into _auto_detect_path to fully isolate the unit test from real network I/O. |
| CHANGELOG.md | Documents the fix under Unreleased -> Fixed. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
… stub Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The macOS x86_64 unit-test job has been failing intermittently with:
Example failure: https://github.com/microsoft/apm/actions/runs/24597356401/job/71929864401
Root cause
test_auto_detect_through_proxymocked the proxy fetch but did not pass anauth_resolverto_auto_detect_path. When the proxy mock returnsNonefor the first candidate path (marketplace.json),_fetch_filefalls through to the GitHub Contents API path. Because no resolver was provided, a realAuthResolverwas instantiated and made a live HTTP request toapi.github.com— hitting the anonymous rate limit on shared macOS runners.This is the kind of network call we want confined to authenticated integration tests, not unit CI.
Fix
Pass a mock
auth_resolverwhosetry_with_fallbackreturnsNone(simulates "file not found via GitHub fallback"). Probing then advances to the next candidate, which the proxy mock satisfies — verifying the auto-detect probing logic without any real network I/O.Validation
uv run pytest tests/unit/marketplace/test_marketplace_client.py-> 26 passed.