dotnet/aspnetcore · error · InvalidOperationException
Incorrect frame type: '{prevFrame.FrameTypeField}'
Error message
Incorrect frame type: '{prevFrame.FrameTypeField}' What it means
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.
Source
Thrown at src/Components/Components/src/Rendering/RenderTreeBuilder.cs:483
/// </para>
/// <para>
/// This information is used by the rendering system to determine whether
/// to accept a value update for the other attribute when receiving a
/// call to the event handler.
/// </para>
/// </summary>
/// <param name="updatesAttributeName">The name of another attribute whose value can be updated when the event handler is executed.</param>
public void SetUpdatesAttributeName(string updatesAttributeName)
{
if (_entries.Count == 0)
{
throw new InvalidOperationException("No preceding attribute frame exists.");
}
ref var prevFrame = ref _entries.Buffer[_entries.Count - 1];
if (prevFrame.FrameTypeField != RenderTreeFrameType.Attribute)
{
throw new InvalidOperationException($"Incorrect frame type: '{prevFrame.FrameTypeField}'");
}
prevFrame.AttributeEventUpdatesAttributeNameField = updatesAttributeName;
}
/// <summary>
/// Appends a frame representing a child component.
/// </summary>
/// <typeparam name="TComponent">The type of the child component.</typeparam>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
public void OpenComponent<[DynamicallyAccessedMembers(Component)] TComponent>(int sequence) where TComponent : notnull, IComponent
=> OpenComponentUnchecked(sequence, typeof(TComponent));
/// <summary>
/// Appends a frame representing a child component.
/// </summary>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
/// <param name="componentType">The type of the child component.</param>View on GitHub (pinned to 294cab2f9b)
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.
Example fix
// before
builder.OpenElement(0, "input");
builder.AddAttribute(1, "value", currentVal);
builder.SetUpdatesAttributeName("value"); // last frame is a string attribute, but maybe wrong context
// after — ensure the annotated frame is the event handler attribute
builder.OpenElement(0, "input");
builder.AddAttribute(1, "oninput", onInputHandler);
builder.SetUpdatesAttributeName("value"); Defensive patterns
Strategy: validation
Validate before calling
// No public API to check the last frame type; ensure correct ordering // The contract: SetUpdatesAttributeName must follow an Attribute frame // Always add the event handler attribute immediately before calling it
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No preceding attribute frame exists.
- Valueless attributes may only be added immediately after fra
- The FrameType must be Attribute.
- Cannot set a key outside the scope of a component or element
- Cannot set a key on a frame of type {parentFrame.FrameTypeFi
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/340b3eb4aae983b5.
Report an issue: GitHub.