{"record":{"id":"618743a168d8a3a7","repo":"composer/composer","slug":"invalid-repository-url-repository-given-has","errorCode":null,"errorMessage":"Invalid repository url (${repository}) given. Has to be a .json file, an http url or a JSON object.","messagePattern":"Invalid repository url \\((.+?)\\) given\\. Has to be a \\.json file, an http url or a JSON object\\.","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Composer/Repository/RepositoryFactory.php","lineNumber":51,"sourceCode":"    public static function configFromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false)\n    {\n        if (0 === stripos($repository, 'http')) {\n            $repoConfig = ['type' => 'composer', 'url' => $repository];\n        } elseif (\"json\" === pathinfo($repository, PATHINFO_EXTENSION)) {\n            $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));\n            $data = $json->read();\n            if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {\n                $repoConfig = ['type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\\\', '/')];\n            } elseif ($allowFilesystem) {\n                $repoConfig = ['type' => 'filesystem', 'json' => $json];\n            } else {\n                throw new \\InvalidArgumentException(\"Invalid repository URL ($repository) given. This file does not contain a valid composer repository.\");\n            }\n        } elseif (strpos($repository, '{') === 0) {\n            // assume it is a json object that makes a repo config\n            $repoConfig = JsonFile::parseJson($repository);\n        } else {\n            throw new \\InvalidArgumentException(\"Invalid repository url (\".Url::sanitize($repository).\") given. Has to be a .json file, an http url or a JSON object.\");\n        }\n\n        return $repoConfig;\n    }\n\n    public static function fromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false, ?RepositoryManager $rm = null): RepositoryInterface\n    {\n        $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);\n\n        return static::createRepo($io, $config, $repoConfig, $rm);\n    }\n\n    /**\n     * @param  array<string, mixed> $repoConfig\n     */\n    public static function createRepo(IOInterface $io, Config $config, array $repoConfig, ?RepositoryManager $rm = null): RepositoryInterface\n    {\n        if (!$rm) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/composer/composer/blob/6ffc1177404d0c50119c22dde6564a380f4a82c9/src/Composer/Repository/RepositoryFactory.php#L33-L69","documentation":"Thrown by RepositoryFactory::configFromString() (src/Composer/Repository/RepositoryFactory.php:51) when the repository string matches none of the accepted forms: it does not start with 'http', is not a .json file path, and does not begin with '{' (a JSON object literal). The input is therefore unrecognizable as a repository specification.","triggerScenarios":"Calling configFromString() / fromString() with a string that is neither an http(s) URL, a path to a .json file, nor a JSON object string — e.g. a bare 'git@github.com:vendor/pkg.git' SSH url, or a plain word.","commonSituations":"Passing an SSH/SCP-style git URL ('git@host:owner/repo.git') instead of an https URL or a full repo config JSON; passing a directory path that is not a .json file; typos in the CLI repository argument.","solutions":["Use an https(s) URL, a path to a .json file, or a JSON object string (e.g. '{\"type\":\"vcs\",\"url\":\"https://github.com/vendor/pkg\"}').","For SSH git sources, wrap them in a full repository definition JSON with type 'vcs' rather than passing the bare SSH string.","Double-check the extension and scheme of the supplied string."],"exampleFix":"// before\n// configFromString($io,$config,'git@github.com:vendor/pkg.git')\n\n// after\n// configFromString($io,$config,'{\"type\":\"vcs\",\"url\":\"git@github.com:vendor/pkg.git\"}')","handlingStrategy":"validation","validationCode":"if (stripos($repository,'http')!==0\n    && pathinfo($repository,PATHINFO_EXTENSION)!=='json'\n    && !str_starts_with($repository,'{')) {\n    throw new \\InvalidArgumentException('repository string must be an http url, .json path, or JSON object');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass an https URL, a .json file path, or a JSON object string to configFromString.","Wrap SSH/SCP git URLs in a full {\"type\":\"vcs\",\"url\":...} object.","Avoid bare SSH URLs and directory paths."],"tags":["repository-factory","configuration","validation"],"analyzedSha":"6ffc1177404d0c50119c22dde6564a380f4a82c9","analyzedAt":"2026-08-07T00:01:08.491Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}