{"record":{"id":"3254dac351a75e6e","repo":"symfony/symfony","slug":"error-d-requiring-packages-from-jsdelivr-for-s","errorCode":null,"errorMessage":"Error %d requiring packages from jsDelivr for \"%s\". Check your package names. Response: {response_body}","messagePattern":"Error (.+?) requiring packages from jsDelivr for \"(.+?)\"\\. Check your package names\\. Response: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php","lineNumber":132,"sourceCode":"            if (200 !== $response->getStatusCode()) {\n                $getContentErrors[] = [$options->packageModuleSpecifier, $response];\n                continue;\n            }\n\n            $contentType = $response->getHeaders()['content-type'][0] ?? '';\n            $type = str_starts_with($contentType, 'text/css') ? ImportMapType::CSS : ImportMapType::JS;\n            $resolvedPackages[$options->packageModuleSpecifier] = new ResolvedImportMapPackage($options, $version, $type);\n\n            $packagesToRequire = array_merge($packagesToRequire, $this->fetchPackageRequirementsFromImports($response->getContent()));\n        }\n\n        try {\n            ($getContentErrors[0][1] ?? null)?->getHeaders();\n        } catch (HttpExceptionInterface $e) {\n            $response = $e->getResponse();\n            $packages = implode('\", \"', array_column($getContentErrors, 0));\n\n            throw new RuntimeException(\\sprintf('Error %d requiring packages from jsDelivr for \"%s\". Check your package names. Response: ', $response->getStatusCode(), $packages).$response->getContent(false), 0, $e);\n        }\n\n        // process any pending CSS entrypoints\n        $entrypointErrors = [];\n        foreach ($entrypointResponses as $package => [$cssEntrypointResponse, $version]) {\n            if (200 !== $cssEntrypointResponse->getStatusCode()) {\n                $entrypointErrors[] = [$package, $cssEntrypointResponse];\n                continue;\n            }\n\n            $entrypoints = $cssEntrypointResponse->toArray()['entrypoints'] ?? [];\n            $cssFile = $entrypoints['css']['file'] ?? null;\n            $guessed = $entrypoints['css']['guessed'] ?? true;\n\n            if (!$cssFile || $guessed) {\n                continue;\n            }\n","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/symfony/symfony/blob/698e28026c22cf35d032cdb6e800db48b1535790/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php#L114-L150","documentation":"Aggregated HTTP error raised after the package-content download round: one or more requests to `https://cdn.jsdelivr.net/npm/<pkg>@<version>.../+esm` (or the CSS variant) returned non-200, even though version resolution succeeded. The %d is the status code, %s the list of offending package specifiers, followed by the raw response body. Raised in the deferred error block at lines 126-133.","triggerScenarios":"The resolved version exists but the specific dist path or `+esm` build is unavailable (e.g. 404 for a file that was removed in that version); `importmap:install` after a version resolution where the CDN has not yet propagated the build; transient 5xx on jsDelivr CDN; an explicit version pin pointing at a version whose main entry differs.","commonSituations":"Pinning a version that has a different dist layout than expected; requiring a package whose ESM build is not generated by jsDelivr; CDN propagation delay right after a package publish; specifying a path that does not exist in that version (e.g. `/dist/index.js` removed in v2).","solutions":["Read the response body - it usually identifies whether the package, version, or path is wrong.","Drop the explicit path and let the ESM build be used (remove the path, keep useEsm=true).","Try a different version constraint, e.g. `^1` instead of `^2`, if the dist layout changed.","Retry `importmap:install` after a short delay if you suspect CDN propagation."],"exampleFix":"// before\nreturn [\n    'app' => ['path' => 'pkg/old/dist/index.js', 'version' => '^2'],\n];\n\n// after\nreturn [\n    'app' => ['path' => 'pkg', 'version' => '^2'], // use jsDelivr ESM build\n];","handlingStrategy":"try-catch","validationCode":"// Pre-validate the version+path resolves on jsDelivr CDN\nuse Symfony\\Component\\HttpClient\\HttpClient;\n$url = sprintf('https://cdn.jsdelivr.net/npm/%s@%s%s/+esm', $pkg, $version, $path);\n$r = HttpClient::create()->request('GET', $url);\nif (200 !== $r->getStatusCode()) {\n    throw new \\RuntimeException(\"Package content URL $url returned HTTP \".$r->getStatusCode());\n}","typeGuard":"function packageContentFetchable(string $pkg, string $version, string $path, bool $esm): bool {\n    $url = $esm\n        ? sprintf('https://cdn.jsdelivr.net/npm/%s@%s%s/+esm', $pkg, $version, $path)\n        : sprintf('https://cdn.jsdelivr.net/npm/%s@%s%s', $pkg, $version, $path);\n    return 200 === \\Symfony\\Component\\HttpClient\\HttpClient::create()->request('GET', $url)->getStatusCode();\n}","tryCatchPattern":"try {\n    $resolver->resolvePackages($opts);\n} catch (\\Symfony\\Component\\AssetMapper\\Exception\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'requiring packages from jsDelivr')) {\n        // drop explicit path, switch to ESM, or change version\n    }\n    throw $e;\n}","preventionTips":["Prefer the jsDelivr ESM build (bare package name) over pinned dist paths.","When pinning a version, sanity-check the dist layout on https://cdn.jsdelivr.net/npm/<pkg>@<ver>/.","Widen version constraints unless reproducibility demands exact pins."],"tags":["asset-mapper","importmap","jsdelivr","network","http","cdn"],"analyzedSha":"698e28026c22cf35d032cdb6e800db48b1535790","analyzedAt":"2026-08-06T23:40:49.025Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}