From ed9313e6cb024ddadc67135851fa233d01445bd6 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 16 Apr 2026 18:52:04 -0500 Subject: [PATCH] fix: Guzzle base_uri resolution for Gitea API paths Strip leading slash from endpoints and ensure base_uri has trailing slash so Guzzle preserves the /api/v1 path prefix per RFC 3986. Co-Authored-By: Claude Opus 4.6 (1M context) --- automation/bulk_joomla_template.php | 2 +- automation/bulk_sync.php | 2 +- automation/migrate_to_gitea.php | 2 +- automation/push_files.php | 2 +- automation/repo_cleanup.php | 2 +- lib/Enterprise/ApiClient.php | 5 ++++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/automation/bulk_joomla_template.php b/automation/bulk_joomla_template.php index 6d40e83..832cb1b 100644 --- a/automation/bulk_joomla_template.php +++ b/automation/bulk_joomla_template.php @@ -24,7 +24,7 @@ declare(strict_types=1); -require_once __DIR__ . '/../../vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../lib/Enterprise/CliFramework.php'; use MokoEnterprise\{ diff --git a/automation/bulk_sync.php b/automation/bulk_sync.php index b336ee4..0503c9c 100755 --- a/automation/bulk_sync.php +++ b/automation/bulk_sync.php @@ -18,7 +18,7 @@ declare(strict_types=1); -require_once __DIR__ . '/../../vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../lib/Enterprise/CliFramework.php'; use MokoEnterprise\{ diff --git a/automation/migrate_to_gitea.php b/automation/migrate_to_gitea.php index 6dd9754..6c9f24d 100644 --- a/automation/migrate_to_gitea.php +++ b/automation/migrate_to_gitea.php @@ -23,7 +23,7 @@ declare(strict_types=1); -require_once __DIR__ . '/../../vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; use MokoEnterprise\CheckpointManager; use MokoEnterprise\CliFramework; diff --git a/automation/push_files.php b/automation/push_files.php index 8e1f754..abba031 100644 --- a/automation/push_files.php +++ b/automation/push_files.php @@ -18,7 +18,7 @@ declare(strict_types=1); -require_once __DIR__ . '/../../vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../lib/Enterprise/CliFramework.php'; use MokoEnterprise\{ diff --git a/automation/repo_cleanup.php b/automation/repo_cleanup.php index 6f4b4e7..0ad5105 100644 --- a/automation/repo_cleanup.php +++ b/automation/repo_cleanup.php @@ -18,7 +18,7 @@ declare(strict_types=1); -require_once __DIR__ . '/../../vendor/autoload.php'; +require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../lib/Enterprise/CliFramework.php'; use MokoEnterprise\{ApiClient, AuditLogger, CLIApp, Config, GitPlatformAdapter, MetricsCollector, PlatformAdapterFactory}; diff --git a/lib/Enterprise/ApiClient.php b/lib/Enterprise/ApiClient.php index ab695df..c97814f 100644 --- a/lib/Enterprise/ApiClient.php +++ b/lib/Enterprise/ApiClient.php @@ -166,7 +166,7 @@ class ApiClient // Initialize HTTP client $this->httpClient = new Client([ - 'base_uri' => $this->baseUrl, + 'base_uri' => rtrim($this->baseUrl, '/') . '/', 'timeout' => 30, 'headers' => [ 'User-Agent' => $this->userAgent, @@ -281,6 +281,9 @@ class ApiClient // Check rate limit $this->checkRateLimit(); + // Ensure endpoint is relative so Guzzle base_uri path is preserved + $endpoint = ltrim($endpoint, '/'); + // Add authentication if ($this->authToken) { $options['headers']['Authorization'] = $this->authScheme . ' ' . $this->authToken;