Provider IDs with a trailing newline are silently accepted and propagated
Maintainers usually reply within 1 day
@Batianxieshen1 is already working on this.
Since Nov 21, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in api/models/provider_ids.py, in GenericProviderID.__init__, where the two ^...$ patterns are checked with re.match. The repro is in the issue: GenericProviderID("langgenius/openai/gpt\n") and GenericProviderID("openai\n") should raise ValueError("Invalid plugin id ...") but currently do not. Run those two cases, and the subclasses that share the constructor, to confirm the fix.
Written by the indexing model from the issue text.
Description
Describe the bug
GenericProviderID.__init__ in api/models/provider_ids.py validates a plugin
/provider identifier with two regular expressions that are both anchored with
^...$ and matched with re.match. In Python, $ matches at the end of the
string or just before a trailing newline, so an identifier ending in \n
passes both checks. value.split("/") then keeps the newline inside the
parsed segments.
The subclasses (ModelProviderID, ToolProviderID, DatasourceProviderID,
TriggerProviderID) share this constructor, so every typed provider ID is
affected.
Real user path
Provider identifier strings reach GenericProviderID from user-facing
inputs. Console API endpoints build the ID directly from a request parameter;
for example api/controllers/console/workspace/tool_providers.py calls
ToolProviderID(provider) inside a get(..., provider: str) handler and then
uses tool_provider.plugin_id and tool_provider.provider_name for the
downstream lookup. api/core/plugin/provider_identity.py (used for
plugin-daemon transport) also rebuilds an ID as
GenericProviderID(f"{normalized_plugin_id}/{provider_id.provider_name}") and
returns normalized_provider_id.plugin_id.
A value read from a file, an environment variable, a DSL import or an API
payload can retain a trailing newline (for instance a provider name read from
a line-oriented configuration without stripping). Such a value currently
passes validation, and the newline becomes part of organization,
plugin_name or provider_name. The resulting plugin_id and the lookups
built from it no longer match the intended provider, so the request fails to
resolve the plugin/provider instead of reporting an invalid identifier.
To reproduce
from models.provider_ids import GenericProviderID
p = GenericProviderID("langgenius/openai/gpt\n")
assert p.provider_name == "gpt\n"
q = GenericProviderID("openai\n")
assert q.plugin_name == "openai\n"
assert q.provider_name == "openai\n"
Expected behavior
An identifier containing any character outside [a-z0-9_-] and the /
separators - including a trailing newline - should be rejected with
ValueError("Invalid plugin id ..."), in line with the validation intent of
the two regular expressions.
Actual behavior
Both checks use re.match(r"^...$", value). re.match accepts the value
because $ also matches immediately before a trailing newline, so no
exception is raised and the polluted segments are stored.
Environment
- dify
origin/main(63069f5f) - Python 3.11+
- Dominant language
- Python
- Stars
- 162k
- Forks
- 25.6k
- Avg merge
- 15h 9m
- Merged PRs (30d)
- 606
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from langgenius/dify
-
OpenSearch: text_exists() queries OpenSearch _id instead of metadata.doc_id, so it always returns False for indexed chunksPossibly taken @SanemIzci claimed this 1 day ago. Open🐞 bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langgenius/dify#47109 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Log only execution identifiers when a workflow worker starts a runPossibly taken @kinglegendzzh claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langgenius/dify#47094 · 2 reactions ·
Maintainers usually reply within 1 day
-
Node.js SDK declares a response body for 204 conversation deletionPossibly taken @Wang-Zephyr claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
langgenius/dify#46883 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Agent Python SDK polling rejects function-tool results that SSE acceptsPossibly taken @EndlessRoad-max claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
langgenius/dify#46868 · 1 reaction ·
Maintainers usually reply within 1 day
-
Web app: opening statement floats mid-screen after the inputs form collapses (large blank gap)Possibly taken @DanShinde claimed this 4 days ago. Open🐞 bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/dify#46532 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/graphon#443 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authenticationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
docling-project/docling-serve#788 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainers usually reply within 1 day