Skip to content

test(marketplace): isolate test_auto_detect_through_proxy from real network#759

Merged
danielmeppiel merged 2 commits intomainfrom
fix/marketplace-test-network-isolation
Apr 19, 2026
Merged

test(marketplace): isolate test_auto_detect_through_proxy from real network#759
danielmeppiel merged 2 commits intomainfrom
fix/marketplace-test-network-isolation

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Problem

The macOS x86_64 unit-test job has been failing intermittently with:

FAILED tests/unit/marketplace/test_marketplace_client.py::TestProxyAwareFetch::test_auto_detect_through_proxy
  apm_cli.marketplace.errors.MarketplaceFetchError: Failed to fetch marketplace 'acme':
  403 Client Error: rate limit exceeded for url:
  https://api.github.com/repos/acme-org/plugins/contents/marketplace.json?ref=main

Example failure: https://github.com/microsoft/apm/actions/runs/24597356401/job/71929864401

Root cause

test_auto_detect_through_proxy mocked the proxy fetch but did not pass an auth_resolver to _auto_detect_path. When the proxy mock returns None for the first candidate path (marketplace.json), _fetch_file falls through to the GitHub Contents API path. Because no resolver was provided, a real AuthResolver was instantiated and made a live HTTP request to api.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_resolver whose try_with_fallback returns None (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.

…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>
Copilot AI review requested due to automatic review settings April 19, 2026 06:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_resolver into test_auto_detect_through_proxy to prevent _fetch_file from instantiating a real AuthResolver and calling api.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

Comment thread CHANGELOG.md Outdated
Comment thread tests/unit/marketplace/test_marketplace_client.py Outdated
… stub

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danielmeppiel danielmeppiel merged commit 28afcdd into main Apr 19, 2026
6 checks passed
@danielmeppiel danielmeppiel deleted the fix/marketplace-test-network-isolation branch April 19, 2026 06:25
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.

2 participants