Skip to content

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

Open

Description

@indexGin

Summary

Importing a DSL / app from a GitHub file link does not work when the URL host contains uppercase letters. Dify resolves GitHub blob links to raw.githubusercontent.com links with libs.url_utils.github_blob_to_raw_url before downloading an import source. That helper only accepts the exact lowercase host github.com, so a link such as https://GitHub.com/... is returned unchanged instead of being pointed at the raw file.

Affected code path

github_blob_to_raw_url is called by the DSL/app import paths:

  • api/services/app_dsl_service.py — yaml_url = github_blob_to_raw_url(yaml_url)
  • api/services/app_import_source.py — url = github_blob_to_raw_url(url)
  • api/services/rag_pipeline/rag_pipeline_dsl_service.py — yaml_url = github_blob_to_raw_url(yaml_url)
  • api/services/workflow/dsl_import.py — fetch_yaml_url calls it for URLs whose path ends with .yml / .yaml, before raise_for_status() and decoding the response as UTF-8 YAML

In api/libs/url_utils.py the guard includes parsed.netloc != "github.com", and the function rewrites the netloc to raw.githubusercontent.com only when that guard passes.

Reproduction

The helper is a pure function, so the mismatch reproduces directly:

from libs.url_utils import github_blob_to_raw_url

lower = "https://github.com/acme/app/blob/main/dsl.yml"
upper = "https://GitHub.com/acme/app/blob/main/dsl.yml"

github_blob_to_raw_url(lower)
# 'https://raw.githubusercontent.com/acme/app/main/dsl.yml'

github_blob_to_raw_url(upper)
# 'https://GitHub.com/acme/app/blob/main/dsl.yml'   (unchanged)

End to end: store a valid DSL YAML file at https://github.com/<owner>/<repo>/blob/main/app.yml and import it in Dify. With the lowercase host the link is converted to the raw file URL (the result above). With the same link spelled https://GitHub.com/<owner>/<repo>/blob/main/app.yml, the link is not converted, so the import request keeps the blob page URL rather than the raw file URL.

Expected behavior

URL host names are case-insensitive (RFC 3986 section 3.2.2). github_blob_to_raw_url should treat github.com, GitHub.com, and GITHUB.COM identically and return the same https://raw.githubusercontent.com/<owner>/<repo>/<ref>/<file> URL for each. Links that are not GitHub blob file URLs — other hosts, GitHub subdomains, tree paths, non-HTTPS schemes — should keep being returned unchanged.

Activity

  1. dosubot commented on Nov 20, 2026

    @dosubot

    This is separate from the path-corruption bug addressed by #44280, merged October 30. That PR centralized the four import paths, but the shared helper still compares parsed.netloc to the exact string "github.com", leaving mixed-case hosts unchanged. [1]

    A workaround is to supply the raw URL directly, for example https://raw.githubusercontent.com/<owner>/<repo>/main/app.yml. The helper leaves that host unchanged, and the YAML importer downloads the resulting URL directly, bypassing the blob-to-raw conversion. [1] [2]

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions