PHP SDK drops the API path prefix when a custom base URL has no trailing slash
Maintainers usually reply within 1 day
@Winoren is already working on this.
Since Oct 23, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Find the shared PHP SDK constructor that passes the custom API URL to Guzzle as base_uri, then inspect the focused regression tests mentioned in the issue. Reproduce the request with a base URL ending in /v1 and confirm the request keeps that prefix with or without a trailing slash. Done when the four client classes preserve the API path and the default cloud endpoint remains /v1/.
Written by the indexing model from the issue text.
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is a bug report rather than a general question.
- I searched open and closed issues/PRs for PHP base URL, trailing slash, and path-prefix fixes; I found no matching contribution.
- This report is in English.
Dify version
Source main at 9f759255 (PHP SDK using locked Guzzle 7.15.5).
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
Configure the PHP SDK with the API directory URL without a trailing slash:
$client = new DifyClient('your-api-key', 'https://your-dify-host/dify/v1');
$response = $client->get_application_parameters('user-id');
The constructor passes that string directly to Guzzle's base_uri. Guzzle resolves the relative parameters endpoint against it as though v1 were a filename, producing /dify/parameters instead of /dify/v1/parameters. The simpler base https://your-dify-host/v1 similarly produces /parameters.
The shared constructor also affects ChatClient, CompletionClient and WorkflowClient. Appending / to the configured API directory is a workaround.
Expected Behavior
The SDK's custom API base URL preserves its complete directory prefix, with or without a trailing slash. The default cloud endpoint remains /v1/.
Actual Behavior
The last component of the base URL is dropped and requests go to the wrong endpoint, commonly returning 404.
Executed reproduction
Using PHP 8.5.10 via PHP.wasm CLI 3.1.57 and Guzzle 7.15.5, a local HTTP fixture accepts /dify/v1/parameters?user=test-user:
- Original SDK: actual request
/dify/parameters?user=test-user, HTTP 404. - Directory-normalized constructor: actual request
/dify/v1/parameters?user=test-user, HTTP 200, expected Authorization header retained.
An offline Guzzle transport regression also fails on the original source and passes 28 cases with the fix: default URL, bare host, API prefix and nested deployment prefix, with/without trailing slash, across GET and POST methods in all four client classes. It checks exact request URI, method, authentication, payload and response status. No deployed Dify, provider/model request or production measurement is claimed.
Proposed change: ensure the shared constructor's API directory ends in /, add focused tests, and document the self-hosted URL convention. This is independent of the streaming option fix in #44271.
Investigated and verified with Codex assistance.
- Dominant language
- Python
- Stars
- 159k
- Forks
- 25.2k
- Avg merge
- 23h 53m
- Merged PRs (30d)
- 605
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
-
Custom tool sends a form-encoded body when the request body content type is application/json; charset=utf-8Possibly taken @Revinand claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langgenius/dify#44907 · 1 reaction ·
Maintainers usually reply within 1 day
-
[Bug] DOCX table cells with manual line breaks still split Markdown tables in knowledge-base extractionPossibly taken @Tong-bit-art claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
langgenius/dify#44498 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
PHP workflow streaming requests buffer the full SSE responsePossibly taken @Winoren claimed this 10 days ago. Openreview: medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
langgenius/dify#44270 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Node.js SDK rejects attachment-only hit testing with an empty queryPossibly taken @Winoren claimed this 10 days ago. Openreview: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
langgenius/dify#44266 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Node.js SDK rejects empty first-page pagination cursorsPossibly taken @Winoren claimed this 10 days ago. Openreview: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
langgenius/dify#44264 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
PAC Wording
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Harmony OPeNDAP SubSetter (HOSS) Geographic production rssmif16d 7 XYZ_PROV
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
nasa/harmony-autotester#372 ·
-
Add DomainOpen
Difficulty 1/5 Under an hour Newbie friendliness 65/100
disposable/disposable#318 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
developmentseed/titiler-cmr#270 ·
Maintainers usually reply within 1 day
-
Chart: a failed venv install is marked ready, and the 10Gi venv PVC is too small for itPossibly taken @andyne13 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day