{"record":{"id":"340b3eb4aae983b5","repo":"dotnet/aspnetcore","slug":"incorrect-frame-type-prevframe-frametypefield","errorCode":null,"errorMessage":"Incorrect frame type: '{prevFrame.FrameTypeField}'","messagePattern":"Incorrect frame type: '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Rendering/RenderTreeBuilder.cs","lineNumber":483,"sourceCode":"    /// </para>\n    /// <para>\n    /// This information is used by the rendering system to determine whether\n    /// to accept a value update for the other attribute when receiving a\n    /// call to the event handler.\n    /// </para>\n    /// </summary>\n    /// <param name=\"updatesAttributeName\">The name of another attribute whose value can be updated when the event handler is executed.</param>\n    public void SetUpdatesAttributeName(string updatesAttributeName)\n    {\n        if (_entries.Count == 0)\n        {\n            throw new InvalidOperationException(\"No preceding attribute frame exists.\");\n        }\n\n        ref var prevFrame = ref _entries.Buffer[_entries.Count - 1];\n        if (prevFrame.FrameTypeField != RenderTreeFrameType.Attribute)\n        {\n            throw new InvalidOperationException($\"Incorrect frame type: '{prevFrame.FrameTypeField}'\");\n        }\n\n        prevFrame.AttributeEventUpdatesAttributeNameField = updatesAttributeName;\n    }\n\n    /// <summary>\n    /// Appends a frame representing a child component.\n    /// </summary>\n    /// <typeparam name=\"TComponent\">The type of the child component.</typeparam>\n    /// <param name=\"sequence\">An integer that represents the position of the instruction in the source code.</param>\n    public void OpenComponent<[DynamicallyAccessedMembers(Component)] TComponent>(int sequence) where TComponent : notnull, IComponent\n        => OpenComponentUnchecked(sequence, typeof(TComponent));\n\n    /// <summary>\n    /// Appends a frame representing a child component.\n    /// </summary>\n    /// <param name=\"sequence\">An integer that represents the position of the instruction in the source code.</param>\n    /// <param name=\"componentType\">The type of the child component.</param>","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Rendering/RenderTreeBuilder.cs#L465-L501","documentation":"SetUpdatesAttributeName was called when the most recent frame is not an Attribute frame. The method must tag a preceding Attribute frame; any other frame type (Element, Component, Region, etc.) is rejected as 'Incorrect frame type'.","triggerScenarios":"Calling SetUpdatesAttributeName after OpenElement, AddContent, CloseElement, or any non-attribute Append. Pipeline/ordering bugs in custom RenderTreeBuilder code or generated emitters.","commonSituations":"Tree builders that interleave content frames between the handler attribute and the SetUpdatesAttributeName call. Buggy source generators / Razor compilation. Test fakes that don't track frame order.","solutions":["Reorder so the immediately preceding frame is the Attribute being tagged.","Before calling, check _entries last frame type (in custom code: track the last frame type yourself).","Use the higher-level AddAttribute overloads which preserve correct ordering automatically."],"exampleFix":"// before\nbuilder.AddAttribute(0, \"onclick\", handler);\nbuilder.AddContent(1, \"Click\");\nbuilder.SetUpdatesAttributeName(\"value\"); // last frame is now content\n\n// after\nbuilder.AddAttribute(0, \"onclick\", handler);\nbuilder.SetUpdatesAttributeName(\"value\");\nbuilder.AddContent(1, \"Click\");","handlingStrategy":"validation","validationCode":"// Guard before calling\nif (lastFrameType != RenderTreeFrameType.Attribute)\n    throw new InvalidOperationException(\"Last frame must be Attribute.\");\nbuilder.SetUpdatesAttributeName(name);","typeGuard":"static bool LastFrameIsAttribute(RenderTreeFrameType t) => t == RenderTreeFrameType.Attribute;","tryCatchPattern":null,"preventionTips":["Reorder emission so the tagged Attribute frame is immediately preceding.","Don't interleave content/element frames between the attribute and SetUpdatesAttributeName."],"tags":["blazor","render-tree-builder","event-handler","ordering","frame-type"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}