Skip to content

fix(import): preserve GitHub blob URL path components - #44280

Merged
crazywoola merged 2 commits into
langgenius:mainfrom
Winoren:fix/github-import-blob-path
Oct 30, 2026
Merged

crazywoola merged 2 commits into
langgenius:mainfrom
Winoren:fix/github-import-blob-path

Conversation

@Winoren

@Winoren Winoren commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #44279.

GitHub YAML imports can fetch the wrong URL when the owner or file path contains blob. Three import services replace every /blob/, corrupting real directories and query values; the App source downloader removes the first occurrence, which may be the owner. RAG pipeline import also rewrites non-repository GitHub attachments.

Add a shared URL helper in the existing libs.url_utils owner that recognizes /owner/repo/blob/<ref-and-file-path> and removes only the structural file-view marker. Preserve the owner, repository, remaining path, query, and fragment; leave other URLs unchanged. Reuse it in App source, App YAML, RAG pipeline YAML, and OpenAPI DSL import so this one rewrite rule is fixed together. Existing download transports, size bounds, parsing, and transaction ownership remain in their current services.

Example:

Before: github.com/org/repo/blob/main/templates/blob/flow.yaml?source=/blob/file
Wrong:  raw.githubusercontent.com/org/repo/main/templates/flow.yaml?source=/file
Fixed:  raw.githubusercontent.com/org/repo/main/templates/blob/flow.yaml?source=/blob/file

Related merged #30003 protected App YAML imports of GitHub attachments. Explicit controls retain that behavior and cover the RAG path too.

Validation

  • Before changing production code: 12 regression failures, 7 passing controls, testing actual service download boundaries.
  • After: 177 passed across App source, OpenAPI DSL, App DSL, RAG pipeline DSL, and the additional YAML download-boundary tests.
  • OpenAPI cases exercise DslImportService.prepare through fetching, YAML parsing, and graph preparation, with an HTTP boundary returning 404 for an incorrect URL. App source cases check download selection, binary content, and cleanup. Legacy App/RAG boundary tests deliberately return an empty successful body to stop before resource creation, checking the requested URL and that no transaction starts.
  • Pyrefly 1.3.2: 0 diagnostics across all 8 changed Python files. Ruff 0.16.9 check and format check pass.
  • New-test-double, spec-mock, Base-model, getattr, and session-mock guards pass; git diff --cached --check is clean.
  • Python 3.13.12. One existing Pydantic config deprecation warning remains. No live GitHub resource, archive import completion, deployed Dify, or provider invocation is claimed. Synthetic repository names are URL fixtures. Full monorepo checks and Docker integration were not run; there is no backend build artifact for this change. Remote CI results are tracked separately from these local checks.

Test command (existing backend environment active):

uv run --project api --active --no-sync --with pytest-env --with pytest-mock python -m pytest \
  api/tests/unit_tests/services/test_github_import_urls.py \
  api/tests/unit_tests/services/test_app_import_source.py \
  api/tests/unit_tests/services/workflow/test_dsl_import.py \
  api/tests/unit_tests/services/test_app_dsl_service.py \
  api/tests/unit_tests/services/rag_pipeline/test_rag_pipeline_dsl_service.py \
  -q -o addopts=''

CI follow-up

Added extensionless download URL controls at all three YAML import boundaries after Codecov reported partial coverage on their extension checks. The five related test files now pass 180 tests; local branch coverage confirms both outcomes of each changed extension check execute. Targeted Ruff lint/format and whitespace checks pass. No production code changed in this follow-up.

Screenshots

Not applicable (import URL selection).

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly (shared helper docstring).
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

AI assistance: Codex investigated, implemented, and ran the checks above. No independent human review is claimed.

From Codex

@ghfind-review ghfind-review Bot added the review: medium ghfind author score; see https://ghfind.com label Oct 18, 2026
@github-actions github-actions Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 77.07% 77.07% +0.00%
Strict coverage 76.74% 76.75% +0.00%
Typed symbols 67,174 67,186 +12
Untyped symbols 20,072 20,072 0
Modules 3934 3935 +1

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.87%. Comparing base (ed5da3d) to head (8c9bc29).
⚠️ Report is 128 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44280      +/-   ##
==========================================
+ Coverage   88.56%   88.87%   +0.30%     
==========================================
  Files        5510     5568      +58     
  Lines      328616   334983    +6367     
  Branches    65246    66136     +890     
==========================================
+ Hits       291037   297713    +6676     
+ Misses      32385    32024     -361     
- Partials     5194     5246      +52     
Flag Coverage Δ
api 89.11% <100.00%> (+0.51%) ⬆️

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.

@crazywoola
crazywoola added this pull request to the merge queue Oct 30, 2026
Merged via the queue into langgenius:main with commit ae37984 Oct 30, 2026
44 checks passed
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: medium ghfind author score; see https://ghfind.com size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub import URL rewriting removes real blob path components

2 participants