{"record":{"id":"3a371a7dba75b8ce","repo":"dotnet/aspnetcore","slug":"the-nameof-frame-frametype-must-be-rendertreef","errorCode":null,"errorMessage":"The {nameof(frame.FrameType)} must be {RenderTreeFrameType.Attribute}.","messagePattern":"The (.+?) must be (.+?)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Rendering/RenderTreeBuilder.cs","lineNumber":428,"sourceCode":"            AssertCanAddAttribute();\n        }\n    }\n\n    /// <summary>\n    /// <para>\n    /// Appends a frame representing an attribute.\n    /// </para>\n    /// <para>\n    /// The attribute is associated with the most recently added element.\n    /// </para>\n    /// </summary>\n    /// <param name=\"sequence\">An integer that represents the position of the instruction in the source code.</param>\n    /// <param name=\"frame\">A <see cref=\"RenderTreeFrame\"/> holding the name and value of the attribute.</param>\n    public void AddAttribute(int sequence, RenderTreeFrame frame)\n    {\n        if (frame.FrameTypeField != RenderTreeFrameType.Attribute)\n        {\n            throw new ArgumentException($\"The {nameof(frame.FrameType)} must be {RenderTreeFrameType.Attribute}.\");\n        }\n\n        AssertCanAddAttribute();\n        frame.SequenceField = sequence;\n        _entries.Append(frame);\n    }\n\n    /// <summary>\n    /// Adds frames representing multiple attributes with the same sequence number.\n    /// </summary>\n    /// <param name=\"sequence\">An integer that represents the position of the instruction in the source code.</param>\n    /// <param name=\"attributes\">A collection of key-value pairs representing attributes.</param>\n    public void AddMultipleAttributes(int sequence, IEnumerable<KeyValuePair<string, object>>? attributes)\n    {\n        // Calling this up-front just to make sure we validate before mutating anything.\n        AssertCanAddAttribute();\n\n        if (attributes != null)","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Rendering/RenderTreeBuilder.cs#L410-L446","documentation":"AddAttribute(int sequence, RenderTreeFrame frame) was called with a frame whose FrameTypeField is not Attribute. The overload accepts a raw frame and validates it is an attribute frame; anything else (Element, Component, etc.) is an ArgumentException.","triggerScenarios":"Passing an arbitrary RenderTreeFrame retrieved from a tree walk into AddAttribute. Constructing a RenderTreeFrame manually with the wrong FrameType and forwarding it.","commonSituations":"Custom tree-manipulation utilities. Code that copies frames between builders and forwards the wrong slot. Misuse in tests/fakes.","solutions":["Check frame.FrameType == RenderTreeFrameType.Attribute before calling AddAttribute(seq, frame).","Construct attribute frames via RenderTreeFrame.Attribute(...) factory rather than hand-built structs.","If forwarding from another tree, filter by FrameType first."],"exampleFix":"// before\nbuilder.AddAttribute(0, someFrame); // someFrame.FrameType may be Element\n\n// after\nif (someFrame.FrameTypeField == RenderTreeFrameType.Attribute)\n{\n    builder.AddAttribute(0, someFrame);\n}","handlingStrategy":"type-guard","validationCode":"if (frame.FrameTypeField != RenderTreeFrameType.Attribute)\n    throw new ArgumentException(\"Frame must be an Attribute frame.\");\nbuilder.AddAttribute(seq, frame);","typeGuard":"static bool IsAttributeFrame(in RenderTreeFrame f) => f.FrameTypeField == RenderTreeFrameType.Attribute;","tryCatchPattern":null,"preventionTips":["Construct frames via RenderTreeFrame.Attribute(...) factory.","Filter frames by FrameType before forwarding into AddAttribute."],"tags":["blazor","render-tree-builder","attribute","validation","api-misuse"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}