Skip to content

fix(import): convert capitalized github blob urls to raw urls - #46829

Open
indexGin wants to merge 1 commit into
langgenius:mainfrom
indexGin:fix/d1120-dify13-github-blob-host-case
Open

indexGin wants to merge 1 commit into
langgenius:mainfrom
indexGin:fix/d1120-dify13-github-blob-host-case

Conversation

@indexGin

@indexGin indexGin commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

libs.url_utils.github_blob_to_raw_url compared parsed.netloc with the literal "github.com". Because URL host names are case-insensitive (RFC 3986 section 3.2.2), a GitHub blob link whose host contains uppercase letters (https://GitHub.com/...) failed the guard and was returned unchanged, so the DSL/app import paths that call this helper never resolved it to a raw.githubusercontent.com file URL.

This PR compares the network location case-insensitively:

-        or parsed.netloc != "github.com"
+        or parsed.netloc.lower() != "github.com"

The rest of the guard (https scheme, path shape, blob segment) and the conversion itself are untouched, so non-GitHub hosts, GitHub subdomains, tree paths, and non-HTTPS URLs are still returned unchanged.

Tests

Added api/tests/unit_tests/libs/test_github_blob_url_host_case.py (4 tests): capitalized / mixed-case / uppercase hosts, plus regressions for the lowercase host, query-and-fragment preservation, and non-matching URLs (other host, subdomain, tree path, http scheme).

Verification (isolated worktree based on origin/main, PYTHONPATH=$PWD, --noconftest):

  • Source reverted (before fix): 1 failed, 3 passed
  • Fix applied: 4 passed
  • Source reverted again: 1 failed, 3 passed
  • Fix re-applied: 4 passed

Gates: ruff check (all checks passed), ruff format --check (2 files already formatted), pyrefly check with the default config and with the tests/unit_tests/pyrefly.toml strict config (0 diagnostics each), scripts/check_no_new_cast.py (no new typing.cast), and git merge-tree --write-tree origin/main <head> (exit 0). The new test uses explicit -> None return annotations, no empty-container inference, and no pytest.raises without match.

Fixes #46827

URL host names are case-insensitive (RFC 3986), but github_blob_to_raw_url compared parsed.netloc against "github.com" case-sensitively. A GitHub file link such as https://GitHub.com/owner/repo/blob/main/app.yml was therefore returned unchanged, so DSL/app imports requested the blob HTML page instead of the raw YAML file and failed to parse it.

Compare the network location case-insensitively; the remaining guards (scheme, path shape, blob segment) are untouched.

Add a unit test for capitalized hosts and regressions for lowercase hosts, query/fragment preservation, and non-matching URLs.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 07:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 87.03% 87.03% +0.00%
Strict coverage 86.69% 86.69% +0.00%
Typed symbols 95,803 95,807 +4
Untyped symbols 14,328 14,328 0
Modules 4633 4634 +1

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (89c2d66) to head (8e0bc79).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46829      +/-   ##
==========================================
- Coverage   90.29%   90.29%   -0.01%     
==========================================
  Files        6459     6459              
  Lines      407508   407482      -26     
  Branches    81825    81825              
==========================================
- Hits       367960   367933      -27     
- Misses      33141    33146       +5     
+ Partials     6407     6403       -4     
Flag Coverage Δ
api 90.09% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing a DSL from a GitHub blob URL fails when the host is capitalized

2 participants