{"record":{"id":"43ab4411e957377c","repo":"dotnet/aspnetcore","slug":"invalid-sequence-number-or-identifier-sequenceo","errorCode":null,"errorMessage":"Invalid sequence number or identifier '${sequenceOrIdentifier}'.","messagePattern":"Invalid sequence number or identifier '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts","lineNumber":559,"sourceCode":"    this.changeActivity(1);\n    return sendJSDataStream(this._connection!, data, streamId, chunkSize, () => this.changeActivity(-1));\n  }\n\n  public resolveElement(sequenceOrIdentifier: string): LogicalElement {\n    // It may be a root component added by JS\n    const jsAddedComponentContainer = getAndRemovePendingRootComponentContainer(sequenceOrIdentifier);\n    if (jsAddedComponentContainer) {\n      return toLogicalElement(jsAddedComponentContainer, true);\n    }\n\n    // ... or it may be a root component added by .NET\n    const parsedSequence = Number.parseInt(sequenceOrIdentifier);\n    if (!Number.isNaN(parsedSequence)) {\n      const descriptor = this._componentManager.resolveRootComponent(parsedSequence);\n      return toLogicalRootCommentElement(descriptor);\n    }\n\n    throw new Error(`Invalid sequence number or identifier '${sequenceOrIdentifier}'.`);\n  }\n\n  public getRootComponentManager(): RootComponentManager<ServerComponentDescriptor> {\n    return this._componentManager;\n  }\n\n  public getEventRegistry(): JSEventRegistry {\n    return this._eventRegistry;\n  }\n\n  private unhandledError(err: Error): void {\n    this._logger.log(LogLevel.Error, err);\n\n    // Disconnect on errors.\n    // Trying to call methods on the connection after its been closed will throw.\n    this.disconnect();\n  }\n","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Platform/Circuits/CircuitManager.ts#L541-L577","documentation":"Thrown by CircuitManager.resolveElement() when the sequenceOrIdentifier is neither a pending JS-added root component container nor a parseable integer sequence number. resolveElement first checks the pending JS container map, then tries Number.parseInt; if both fail the string is not a valid root component target and is rejected.","triggerScenarios":"Server sends a JS.AttachComponent message with a selector/sequence that does not match any registered JS root component container and is not numeric; a malformed component descriptor; mismatched root component registration between server and the JS RegisteredComponents map.","commonSituations":"Registering root components for JS Blazor (Blazor.rootComponents.registerForJS / add) with a selector that the server references but the client never declared; version skew in component descriptor format; typos in component selector strings.","solutions":["Ensure every root component selector the server attaches is either a numeric sequence registered via RootComponentManager or a container declared client-side via Blazor.rootComponents.add.","Verify RegisteredComponents selectors on the .NET side match the JS registrations exactly.","Match client/server framework versions so the descriptor/selector contract is consistent."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate a selector/sequence before resolving:\nfunction isValidTarget(s: string): boolean {\n  return /^\\d+$/.test(s) || pendingContainerExists(s);\n}\nif (!isValidTarget(selector)) { throw new Error('Bad root target: ' + selector); }","typeGuard":"function isRootSequence(s: string): boolean {\n  return /^\\d+$/.test(s);\n}","tryCatchPattern":null,"preventionTips":["Keep .NET RegisteredComponents selectors in sync with client Blazor.rootComponents registrations.","Use numeric sequences or explicitly-registered container selectors only.","Match client/server framework versions."],"tags":["blazor","root-components","selector","interop"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}