{"record":{"id":"f258c64abaf1f1ea","repo":"ansible/ansible","slug":"collections-requirement-source-entry-should-cont","errorCode":null,"errorMessage":"Collections requirement 'source' entry should contain a valid Galaxy API URL but it does not: {not_url!s} is not an HTTP URL.","messagePattern":"Collections requirement 'source' entry should contain a valid Galaxy API URL but it does not: (.+?) is not an HTTP URL\\.","errorType":"exception","errorClass":"AnsibleError","httpStatus":null,"severity":"error","filePath":"lib/ansible/galaxy/dependency_resolution/dataclasses.py","lineNumber":457,"sourceCode":"                'one of file, galaxy, git, dir, subdirs, or url.'\n            )\n\n        if req_name is None and req_type == 'galaxy':\n            raise AnsibleError(\n                'Collections requirement entry should contain '\n                \"the key 'name' if it's requested from a Galaxy-like \"\n                'index server.',\n            )\n\n        if req_type != 'galaxy' and req_source is None:\n            req_source, req_name = req_name, None\n\n        if (\n                req_type == 'galaxy' and\n                isinstance(req_source, GalaxyAPI) and\n                not _is_http_url(req_source.api_server)\n        ):\n            raise AnsibleError(\n                \"Collections requirement 'source' entry should contain \"\n                'a valid Galaxy API URL but it does not: {not_url!s} '\n                'is not an HTTP URL.'.\n                format(not_url=req_source.api_server),\n            )\n\n        if (\n                req_type == 'dir'\n                and isinstance(req_source, str)\n                and req_source.endswith(os.path.sep)\n        ):\n            req_source = req_source.rstrip(os.path.sep)\n\n        tmp_inst_req = cls(req_name, req_version, req_source, req_type, req_signature_sources)\n\n        if req_type not in {'galaxy', 'subdirs'} and req_name is None:\n            req_name = art_mgr.get_direct_collection_fqcn(tmp_inst_req)  # TODO: fix the cache key in artifacts manager?\n","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/ansible/ansible/blob/9cf16a4aca7898481c257f1e17ad28d0b67b1f85/lib/ansible/galaxy/dependency_resolution/dataclasses.py#L439-L475","documentation":"Raised in Requirement.from_requirement_dict (lib/ansible/galaxy/dependency_resolution/dataclasses.py) when a galaxy-type requirement's 'source' resolved to a GalaxyAPI object whose api_server is not an HTTP(S) URL. The Galaxy API client is only usable over HTTP, so a non-http api_server (e.g. a hostname, file path, or malformed string) is rejected.","triggerScenarios":"Constructing requirements where 'source' is passed as a GalaxyAPI instance programmatically, or via CLI config where the server URL lacks a scheme (`galaxy.ansible.com` instead of `https://galaxy.ansible.com`), causing _is_http_url(req_source.api_server) to fail.","commonSituations":"ansible.cfg [galaxy] server list entries missing the scheme; custom tooling building GalaxyAPI('https://' stripped) objects; typos like 'htp://'; proxies rewriting configs.","solutions":["Give the server URL a full scheme: `https://galaxy.ansible.com/` in ansible.cfg or requirements source","Verify with `ansible-galaxy collection list --server <url>` that the URL is accepted","In API code, ensure GalaxyAPI is constructed with api_server including http:// or https://"],"exampleFix":"# ansible.cfg before\n[galaxy]\nserver.0.url=galaxy.ansible.com\n\n# after\n[galaxy]\nserver.0.url=https://galaxy.ansible.com/","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef validate_galaxy_server(url):\n    scheme = urlparse(url).scheme\n    if scheme not in ('http', 'https'):\n        raise SystemExit(f'{url}: Galaxy server URL must start with http:// or https://')","typeGuard":"def is_http_url(url: str) -> bool:\n    p = urlparse(url or '')\n    return p.scheme in ('http', 'https') and bool(p.netloc)","tryCatchPattern":null,"preventionTips":["Always write full scheme+host in ansible.cfg galaxy server URLs","Add a config lint step that urlparse-checks every configured Galaxy server"],"tags":["galaxy","url","configuration","collections"],"backgroundTag":null,"analyzedSha":"9cf16a4aca7898481c257f1e17ad28d0b67b1f85","analyzedAt":"2026-08-15T00:15:47.100Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}