{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/Rendering/RenderTreeBuilder.cs#L465-L501","documentation":"RenderTreeBuilder.SetUpdatesAttributeName validates that the most recently added frame is of type Attribute before annotating it. If the last frame is a different type (Element, Component, Text, Region, etc.), it throws InvalidOperationException. SetUpdatesAttributeName can only annotate event handler attribute frames.","triggerScenarios":"Calling builder.SetUpdatesAttributeName after adding a non-attribute frame. For example: builder.OpenElement(0, \"div\"); builder.SetUpdatesAttributeName(\"value\"); — the last frame is Element, not Attribute. The error message includes the actual frame type for diagnosis.","commonSituations":"Incorrect call ordering in manual RenderTreeBuilder code; custom source generators emitting SetUpdatesAttributeName at the wrong position; calling SetUpdatesAttributeName after AddContent or OpenComponent instead of after AddAttribute.","solutions":["Call SetUpdatesAttributeName immediately after the attribute frame it should annotate.","Ensure the immediately preceding frame is an Attribute frame (added via AddAttribute).","Review the generated or manual code sequence: AddAttribute (for the event handler) must be the last frame before SetUpdatesAttributeName.","Debug by checking _entries.Buffer[Count-1].FrameTypeField to confirm it is Attribute."],"exampleFix":"// before\nbuilder.OpenElement(0, \"input\");\nbuilder.AddAttribute(1, \"value\", currentVal);\nbuilder.SetUpdatesAttributeName(\"value\"); // last frame is a string attribute, but maybe wrong context\n\n// after — ensure the annotated frame is the event handler attribute\nbuilder.OpenElement(0, \"input\");\nbuilder.AddAttribute(1, \"oninput\", onInputHandler);\nbuilder.SetUpdatesAttributeName(\"value\");","handlingStrategy":"validation","validationCode":"// No public API to check the last frame type; ensure correct ordering\n// The contract: SetUpdatesAttributeName must follow an Attribute frame\n// Always add the event handler attribute immediately before calling it","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the immediately preceding frame is an Attribute frame before calling SetUpdatesAttributeName.","Never call SetUpdatesAttributeName after OpenElement, OpenComponent, AddContent, or AddMarkupContent.","In manual render code, keep event handler attribute and SetUpdatesAttributeName adjacent.","Review generated code for correct directive attribute (@bind) compilation."],"tags":["blazor","rendertreebuilder","attributes","event-binding","manual-render"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}