{"record":{"id":"35554aa3d9eca764","repo":"reactiveui/refit","slug":"parameter-owner-name-matches-both-a-parameter-an","errorCode":null,"errorMessage":"Parameter {owner.Name} matches both a parameter and nested parameter on a parameter object","messagePattern":"Parameter (.+?) matches both a parameter and nested parameter on a parameter object","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs","lineNumber":249,"sourceCode":"    /// <exception cref=\"ArgumentException\"><paramref name=\"owner\"/> is already bound as a route parameter in its own\n    /// right, so it cannot also supply a nested property.</exception>\n    internal static void AddObjectPropertyParameter(\n        ParameterInfo[] parameterInfo,\n        Dictionary<int, RestMethodParameterInfo> ret,\n        List<ParameterFragment> fragmentList,\n        string name,\n        ParameterInfo owner,\n        IReadOnlyList<PropertyInfo> propertyChain,\n        bool isOptional)\n    {\n        var parameterIndex = Array.IndexOf(parameterInfo, owner);\n\n        // If we already have this parameter, add an additional ParameterProperty.\n        if (ret.TryGetValue(parameterIndex, out var value2))\n        {\n            if (!value2.IsObjectPropertyParameter)\n            {\n                throw new ArgumentException(\n                    $\"Parameter {owner.Name} matches both a parameter and nested parameter on a parameter object\");\n            }\n\n            value2.ParameterProperties.Add(new(name, propertyChain));\n            fragmentList.Add(\n                ParameterFragment.DynamicObject(parameterIndex, value2.ParameterProperties.Count - 1, isOptional));\n            return;\n        }\n\n        var restMethodParameterInfo = new RestMethodParameterInfo(true, owner);\n        restMethodParameterInfo.ParameterProperties.Add(new(name, propertyChain));\n\n        var idx = Array.IndexOf(parameterInfo, restMethodParameterInfo.ParameterInfo);\n        fragmentList.Add(ParameterFragment.DynamicObject(idx, 0, isOptional));\n#if NET6_0_OR_GREATER\n        _ = ret.TryAdd(idx, restMethodParameterInfo);\n#else\n        if (ret.ContainsKey(idx))","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/reactiveui/refit/blob/b455f65ecc4c97d092317e349cb775f9cfc6bcdf/src/Refit.Reflection/RestMethodInfoInternal.ParameterBinding.cs#L231-L267","documentation":"The same parameter index is already present in the parameter map as a direct (non-object-property) binding, and the code is now trying to add an object/nested-property binding for it. Refit forbids a parameter being both a direct route binding and a nested object-property source simultaneously, because the two bindings would conflict.","triggerScenarios":"A method parameter is bound directly to a route placeholder AND the same parameter object is also referenced through a nested property chain for another placeholder, producing a double registration on the same index.","commonSituations":"A parameter object used both as a whole for {param} and decomposed into {param.Prop}; overlapping [AliasAs]/property bindings on a shared object; complex DTO bound multiple ways.","solutions":["Avoid binding the same parameter both directly and via nested properties; split into distinct parameters.","Use [AliasAs] or separate DTOs so each placeholder has a single, unambiguous source.","Review the parameter object's properties and remove the overlapping direct binding."],"exampleFix":"// before\n[Get(\"/{obj}/{obj.Name}\")] Task GetAsync(MyObj obj); // obj bound twice\n\n// after\n[Get(\"/{id}/{name}\")] Task GetAsync(string id, string name);","handlingStrategy":"validation","validationCode":"// Avoid binding the same parameter both directly and via nested property chains.\n// Ensure each placeholder resolves to exactly one source (param or property).","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not reference one parameter object both whole and decomposed in the same template.","Split overlapping bindings into separate, single-purpose parameters.","Review DTO property exposure used in templates."],"tags":["refit","routing","parameter-binding","design-time"],"backgroundTag":null,"analyzedSha":"b455f65ecc4c97d092317e349cb775f9cfc6bcdf","analyzedAt":"2026-08-13T21:20:57.878Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}