Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

PHP SDK drops the API path prefix when a custom base URL has no trailing slash

Closed Beginner friendly
#44,568 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Winoren is already working on this.

Since Oct 23, 2026.

  • #44569 by @Winoren — merged
  • #44574 by @wanjinhao1 — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
api

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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from langgenius/dify

All issues in langgenius/dify

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.