{"record":{"id":"0d6e5c1743f794f8","repo":"composer/composer","slug":"invalid-ignore-rule-for-s-expected-an-object","errorCode":null,"errorMessage":"Invalid ignore rule for \"%s\": expected an object, got %s.","messagePattern":"Invalid ignore rule for \"(.+?)\": expected an object, got (.+?)\\.","errorType":"exception","errorClass":"UnexpectedValueException","httpStatus":null,"severity":"error","filePath":"src/Composer/Policy/IgnorePackageRule.php","lineNumber":110,"sourceCode":"            }\n\n            // Simple string reason: \"vendor/pkg\": \"reason\"\n            if (is_string($value) && !is_int($key)) {\n                $rules[$key][] = new self($key, new MatchAllConstraint(), $value);\n                continue;\n            }\n\n            // Numeric key with string value: [\"vendor/pkg\"]\n            if (is_int($key) && is_string($value)) {\n                $rules[$value][] = new self($value, new MatchAllConstraint());\n                continue;\n            }\n\n            // Array of rule objects: \"vendor/pkg\": [{...}, {...}]\n            if (is_array($value) && !is_int($key) && isset($value[0])) {\n                foreach ($value as $ruleConfig) {\n                    if (!is_array($ruleConfig)) {\n                        throw new \\UnexpectedValueException(sprintf(\n                            'Invalid ignore rule for \"%s\": expected an object, got %s.',\n                            $key,\n                            get_debug_type($ruleConfig)\n                        ));\n                    }\n                    $rules[$key][] = self::fromRuleObject($key, $ruleConfig, $parser);\n                }\n                continue;\n            }\n\n            // Single rule object: \"vendor/pkg\": {\"constraint\": \"...\", ...}\n            if (is_array($value) && !is_int($key)) {\n                $rules[$key][] = self::fromRuleObject($key, $value, $parser);\n                continue;\n            }\n\n            throw new \\UnexpectedValueException(sprintf(\n                'Invalid ignore entry at key \"%s\": value of type %s is not a supported shape.'","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/composer/composer/blob/c435d285c9120efdca35696769c72ea9fdcc0466/src/Composer/Policy/IgnorePackageRule.php#L92-L128","documentation":"Thrown by IgnorePackageRule::parseIgnoreMap() when a package key maps to a list of rule objects but one of the list elements is not an array. Each element of a list-valued ignore entry must itself be a rule-object array (with keys like constraint/reason/on-block); a non-array element (string, int, null) is rejected because it cannot be parsed into an IgnorePackageRule.","triggerScenarios":"parseIgnoreMap() reaches the list-of-rules branch (line 107: is_array($value) && isset($value[0])) and iterates $value; if any $ruleConfig is not an array, line 109-115 throws with the key and get_debug_type() of the offending element. E.g. {\"vendor/pkg\": [{\"constraint\": \"^1.0\"}, \"reason\"]} - second element is a string.","commonSituations":"Mixing a rule-object list with stray scalar entries; a YAML list where an item collapsed to a scalar; copy-paste merging a string reason into a list of objects; an inconsistent config where some entries are objects and one is a bare string.","solutions":["Ensure every element of a list-valued ignore entry is a rule-object array, e.g. {\"vendor/pkg\": [{\"constraint\": \"^1.0\"}, {\"constraint\": \"^3.0\", \"on-block\": false}]}.","If you only need a single rule with no version constraint, use the string-reason or null form instead of a list: {\"vendor/pkg\": \"reason\"} or {\"vendor/pkg\": null}.","Validate the list before parsing: each element of a list-valued entry must be an array.","Check YAML/JSON indentation to ensure list items are objects, not scalars."],"exampleFix":"// before\n{\"ignore\": {\"vendor/pkg\": [{\"constraint\": \"^1.0\"}, \"legacy\"]}}\n// second list element is a string -> throws\n\n// after\n{\"ignore\": {\"vendor/pkg\": [{\"constraint\": \"^1.0\"}, {\"constraint\": \"^2.0\", \"reason\": \"legacy\"}]}}","handlingStrategy":"validation","validationCode":"// Validate list-valued ignore entries before parsing.\nforeach ($config as $key => $value) {\n    if (is_array($value) && !is_int($key) && isset($value[0])) {\n        foreach ($value as $i => $ruleConfig) {\n            if (!is_array($ruleConfig)) {\n                throw new \\UnexpectedValueException(\"ignore[$key][$i] must be a rule object\");\n            }\n        }\n    }\n}\n$rules = \\Composer\\Policy\\IgnorePackageRule::parseIgnoreMap($config);","typeGuard":"/** @param mixed $ruleConfig */\nfunction isRuleObject($ruleConfig): bool {\n    return is_array($ruleConfig);\n}","tryCatchPattern":"try {\n    $rules = IgnorePackageRule::parseIgnoreMap($config);\n} catch (\\UnexpectedValueException $e) {\n    // a list element wasn't an object - convert to {\"constraint\":...} shape\n}","preventionTips":["Each element of a list-valued ignore entry must be a rule-object array.","For single unversioned ignores, use the string-reason or null form instead of a list.","Check YAML/JSON indentation so list items remain objects, not scalars."],"tags":["policy","audit","configuration","validation"],"backgroundTag":null,"analyzedSha":"c435d285c9120efdca35696769c72ea9fdcc0466","analyzedAt":"2026-08-07T18:58:23.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}