octobercms/october · error · ApplicationException

system::lang.server.response_invalid

system::lang.server.response_invalid

Error message

Invalid response from the server.

What it means

After a 200 response, requestServerData() decodes the gateway body with @json_decode; the catch around it throws 'Invalid response from the server' (system::lang.server.response_invalid) if decoding raises. This indicates the update server returned something that is not valid JSON — an HTML error page, a serialized blob, or a truncated body. It is the 'server answered but spoke the wrong protocol' branch of the updater's response validation.

Solutions

  1. Capture the raw response (curl the same endpoint) and inspect what is actually returned instead of JSON
  2. If a captive portal or proxy injects HTML, fix the network path or proxy exclusions for the gateway host
  3. For custom gateways, ensure every endpoint the updater hits emits application/json only
  4. Verify the body isn't truncated by TLS inspection or output compression middleware
Defensive patterns

Strategy: try-catch

Try / catch

try {
    $response = \System\Classes\UpdateManager::instance()->requestServerData($uri, $postData);
} catch (\October\Rain\Exception\ApplicationException $ex) {
    if (str_contains($ex->getMessage(), 'Invalid response')) {
        // gateway spoke non-JSON (captive portal/proxy) — log the context, don't retry blindly
        Log::warning('Update gateway returned non-JSON payload', ['uri' => $uri]);
    }
    throw $ex;
}

Prevention

When it happens

Trigger: Gateway returns 200 with HTML (captive portal, login page, proxy interstitial), partially downloaded body, or BOM/prefix noise before the JSON; any update/marketplace request going through requestServerData().

Common situations: Captive Wi-Fi / hotel portal intercepting HTTPS; a custom update server returning rendered pages on some routes; response compression or charset issues corrupting the body; ISP-level content rewriting.

Understand the failure class

Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/103b6532f9c4b03f. Report an issue: GitHub.

Appendix: source

Thrown at modules/system/classes/updatemanager/HasGatewayAccess.php:62

        if ($result->status() === 404) {
            throw new ApplicationException(Lang::get('system::lang.server.response_not_found'));
        }

        if ($result->status() !== 200) {
            throw new ApplicationException(
                strlen($contents)
                ? $contents
                : Lang::get('system::lang.server.response_empty')
            );
        }

        $resultData = false;

        try {
            $resultData = @json_decode($contents, true);
        }
        catch (Exception $ex) {
            throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
        }

        if ($resultData === false || (is_string($resultData) && !strlen($resultData))) {
            throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
        }

        return $resultData;
    }

    /**
     * requestServerFile downloads a file from the update server.
     * @param string $uri
     * @param string $fileCode
     * @param array $postData
     */
    public function requestServerFile($uri, $fileCode, $postData = [])
    {
        $filePath = $this->getFilePath($fileCode);

View on GitHub (pinned to b608633a7e)