{"record":{"id":"5f0e1c5d8df8024d","repo":"ansible/ansible","slug":"no-hosts-matched-the-subscripted-pattern-s","errorCode":null,"errorMessage":"No hosts matched the subscripted pattern '%s'","messagePattern":"No hosts matched the subscripted pattern '(.+?)'","errorType":"exception","errorClass":"AnsibleError","httpStatus":null,"severity":"error","filePath":"lib/ansible/inventory/manager.py","lineNumber":516,"sourceCode":"        If the pattern matches one or more group names according to these rules,\n        it may have an optional range suffix to select a subset of the results.\n        This is allowed only if the pattern is not a regex, i.e. '~foo[1]' does\n        not work (the [1] is interpreted as part of the regex), but 'foo*[1]'\n        would work if 'foo*' matched the name of one or more groups.\n\n        Duplicate matches are always eliminated from the results.\n        \"\"\"\n\n        if pattern[0] in (\"&\", \"!\"):\n            pattern = pattern[1:]\n\n        if pattern not in self._pattern_cache:\n            (expr, slice) = self._split_subscript(pattern)\n            hosts = self._enumerate_matches(expr)\n            try:\n                hosts = self._apply_subscript(hosts, slice)\n            except IndexError:\n                raise AnsibleError(\"No hosts matched the subscripted pattern '%s'\" % pattern)\n            self._pattern_cache[pattern] = hosts\n\n        return self._pattern_cache[pattern]\n\n    def _split_subscript(self, pattern):\n        \"\"\"\n        Takes a pattern, checks if it has a subscript, and returns the pattern\n        without the subscript and a (start,end) tuple representing the given\n        subscript (or None if there is no subscript).\n\n        Validates that the subscript is in the right syntax, but doesn't make\n        sure the actual indices make sense in context.\n        \"\"\"\n\n        # Do not parse regexes for enumeration info\n        if pattern[0] == '~':\n            return (pattern, None)\n","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/ansible/ansible/blob/9cf16a4aca7898481c257f1e17ad28d0b67b1f85/lib/ansible/inventory/manager.py#L498-L534","documentation":"Error \"No hosts matched the subscripted pattern '%s'\" thrown in ansible/ansible.","triggerScenarios":"Thrown at lib/ansible/inventory/manager.py:516 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the pattern's subscript/slice indices against the number of matched hosts.","Verify the pattern matches the intended hosts with 'ansible-inventory --list'."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9cf16a4aca7898481c257f1e17ad28d0b67b1f85","analyzedAt":"2026-08-15T00:15:47.100Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}