Skip to content

Fix pip config parsing for multiple extra-index-urls#3125

Open
harkrish-1 wants to merge 2 commits intoNetflix:masterfrom
harkrish-1:fix/pip-config-extra-index-url-parsing
Open

Fix pip config parsing for multiple extra-index-urls#3125
harkrish-1 wants to merge 2 commits intoNetflix:masterfrom
harkrish-1:fix/pip-config-extra-index-url-parsing

Conversation

@harkrish-1
Copy link
Copy Markdown

@harkrish-1 harkrish-1 commented Apr 17, 2026

Summary

  • Fix Pip.indices() to correctly parse multiple extra-index-url values from pip config
  • When pip config contains multiple extra-index-urls, pip config list outputs them separated by literal \n characters (backslash + n, not actual newlines)
  • The previous regex (\s+) only split on whitespace, so multiple URLs were treated as a single mangled value
  • The fix adds literal \n as an additional split delimiter: r"\\n|\s+"

Tests

  • Unit tests added/updated
  • Reproduction script provided (required for Core Runtime)
  • CI passes
  • If tests are impractical: explain why below and provide manual evidence above

Non-Goals

AI Tool Usage

  • No AI tools were used in this contribution
  • AI tools were used (describe below)

Used claude code to identify and fix this bug, I completely understand the changes made

When pip config contains multiple extra-index-urls, `pip config list`
outputs them separated by literal `\n` characters. The previous regex
only split on whitespace, so multiple URLs were treated as a single
mangled value. Split on literal `\n` as well.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 17, 2026

Greptile Summary

This PR fixes Pip.indices() to split multiple extra-index-url values that pip config list emits as a single string joined by literal (backslash + n) characters. The one-line regex change and accompanying regression test are both correct and minimal.

Confidence Score: 5/5

Safe to merge; the fix is correct, the test validates the regression, and the only remaining finding is a minor defensive-coding suggestion.

No P0 or P1 issues. The single finding (empty strings from split) is a pre-existing edge case that the PR doesn't worsen in any realistic pip output scenario, and is P2 only.

No files require special attention.

Important Files Changed

Filename Overview
metaflow/plugins/pypi/pip.py Adds \n literal as a split delimiter in indices() to correctly parse multiple extra-index-url values from pip config; fix is logically correct but may admit empty strings into the result list in edge cases
test/unit/test_pip_indices.py New regression test correctly simulates the literal \n separator via a raw string and verifies that both URLs are parsed as distinct entries

Reviews (3): Last reviewed commit: "Add unit tests for Pip.indices() config ..." | Re-trigger Greptile

Comment thread metaflow/plugins/pypi/pip.py
Regression test for the literal \n splitting fix plus coverage for
single index, extra-index, multiple-index priority, empty config,
and config call failure scenarios.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@harkrish-1 harkrish-1 force-pushed the fix/pip-config-extra-index-url-parsing branch from cd6e827 to 5744f99 Compare April 17, 2026 15:18
@harkrish-1
Copy link
Copy Markdown
Author

@savingoyal @saikonen please review and add your feedback. Simple one line change, shouldn't need a lot of time to review.

@romain-intel romain-intel requested a review from saikonen April 20, 2026 06:20
@@ -0,0 +1,24 @@
from unittest.mock import patch
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use pytest, magicmock (pytest-mock plugin), and monkeypatch for the tests. Within pytest, we prefer to use fixtures and non-class-based tests.

@talsperre
Copy link
Copy Markdown
Collaborator

Also make sure to setup the pre-commit hooks insce your code fails on the pre-commit checks in GitHub actions.

@talsperre
Copy link
Copy Markdown
Collaborator

Also the appropriate location for this test file should be inside test/plugins/pip (https://github.com/Netflix/metaflow/tree/master/test/plugins) - i.e., create a new directory for pip and add this test in there.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@6ebc3e4). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3125   +/-   ##
=========================================
  Coverage          ?   26.22%           
=========================================
  Files             ?      375           
  Lines             ?    51431           
  Branches          ?     9069           
=========================================
  Hits              ?    13489           
  Misses            ?    37155           
  Partials          ?      787           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

_, key = key.split(".")
if key in ("index-url", "extra-index-url"):
values = map(lambda x: x.strip("'\""), re.split("\s+", value, re.M))
values = map(lambda x: x.strip("'\""), re.split(r"\\n|\s+", value, re.M))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Change looks straightforward, good catch with this one.

Can you address the other pending review comments still? Otherwise this is good to go.

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.

3 participants