{"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/6ffc1177404d0c50119c22dde6564a380f4a82c9/src/Composer/Policy/IgnorePackageRule.php#L92-L128","documentation":"Thrown by IgnorePackageRule::parseIgnoreMap() when iterating a list-of-rules value (e.g. `\"vendor/pkg\": [{...}, {...}]`) and one of the elements is not an array. Each element of the list must be a rule object (associative array with constraint/reason/on-block/on-audit keys); non-array elements are rejected.","triggerScenarios":"Config like `ignore: { 'vendor/pkg': ['reason', { 'constraint': '^1.0' }] }` where one list element is a string rather than an object. Reached at IgnorePackageRule.php:110 inside the `is_array($value) && isset($value[0])` branch when is_array($ruleConfig) is false for some element.","commonSituations":"Mixing the simple-string reason form with the list-of-objects form; YAML flow style merges values; user assumes positional strings are allowed in the list (they are not — strings belong as the direct value, not inside the list).","solutions":["Make every element of the list an object: `ignore: { 'vendor/pkg': [{ 'constraint': '^1.0' }, { 'constraint': '^3.0' }] }`.","For a single reason string, use the direct form: `ignore: { 'vendor/pkg': 'reason text' }` (no list wrapper).","For one rule with options, use a single object, not a list: `ignore: { 'vendor/pkg': { 'constraint': '^1.0', 'reason': '...' } }`."],"exampleFix":"// before\n['ignore' => ['vendor/pkg' => ['legacy reason', ['constraint' => '^1.0']]]]\n\n// after\n['ignore' => ['vendor/pkg' => [['constraint' => '^1.0', 'reason' => 'legacy']]]]","handlingStrategy":"validation","validationCode":"function ignoreListEntriesAreObjects(array $listValue): bool {\n    foreach ($listValue as $entry) {\n        if (!is_array($entry) || array_is_list($entry) && count($entry) === 0) {\n            // a rule object is associative; reject sequential arrays and non-arrays\n            if (!is_array($entry)) {\n                return false;\n            }\n        }\n    }\n    return true;\n}","typeGuard":"function isIgnoreRuleObject($value): bool {\n    return is_array($value)\n        && (isset($value['constraint']) || isset($value['reason']) || isset($value['on-block']) || isset($value['on-audit']));\n}","tryCatchPattern":null,"preventionTips":["Wrap multi-range ignore rules in objects, never bare strings, inside a list.","Use the direct string form for single reasons instead of a list of one string.","Validate list-of-rules shape with array_is_list detection in a config checker."],"tags":["policy","configuration","validation"],"analyzedSha":"6ffc1177404d0c50119c22dde6564a380f4a82c9","analyzedAt":"2026-08-07T00:01:08.491Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}