{"record":{"id":"b7edb9e8f0c5df6f","repo":"slackhq/nebula","slug":"errinitiateonresponder","errorCode":"ErrInitiateOnResponder","errorMessage":"initiate called on responder","messagePattern":"initiate called on responder","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"handshake/errors.go","lineNumber":6,"sourceCode":"package handshake\n\nimport \"errors\"\n\nvar (\n\tErrInitiateOnResponder     = errors.New(\"initiate called on responder\")\n\tErrInitiateAlreadyCalled   = errors.New(\"initiate already called\")\n\tErrInitiateNotCalled       = errors.New(\"initiate must be called before ProcessPacket for initiators\")\n\tErrPacketTooShort          = errors.New(\"packet too short\")\n\tErrPublicKeyMismatch       = errors.New(\"public key mismatch between certificate and handshake\")\n\tErrIncompleteHandshake     = errors.New(\"handshake completed without receiving required content\")\n\tErrMachineFailed           = errors.New(\"handshake machine has failed\")\n\tErrUnknownSubtype          = errors.New(\"unknown handshake subtype\")\n\tErrMissingContent          = errors.New(\"expected handshake content but message was empty\")\n\tErrUnexpectedContent       = errors.New(\"received unexpected handshake content\")\n\tErrInvalidRemoteIndex      = errors.New(\"peer sent an invalid index in handshake payload\")\n\tErrIndexAllocation         = errors.New(\"failed to allocate local index\")\n\tErrNoCredential            = errors.New(\"no handshake credential available for cert version\")\n\tErrAsymmetricCipherKeys    = errors.New(\"noise produced only one cipher key\")\n\tErrMultiMessageUnsupported = errors.New(\"multi-message handshake patterns are not yet supported by the manager\")\n\tErrSubtypeMismatch         = errors.New(\"packet subtype does not match handshake machine subtype\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/handshake/errors.go#L1-L23","documentation":"ErrInitiateOnResponder is returned by handshake.Machine.Initiate when the machine was created as a responder (not an initiator). Only the initiating peer may call Initiate; a responder machine cannot produce an initiation packet.","triggerScenarios":"Calling Machine.Initiate on a Machine constructed as a responder (initiator=false); test scaffolding creating a responder machine then attempting Initiate, as in machine_test.go:63.","commonSituations":"Misconfiguring which side initiates a connection (e.g. both peers configured as responders, or calling Initiate on the wrong end in tests or connection code); reusing a responder machine to start a new handshake.","solutions":["Ensure only the initiating side constructs its Machine with isInitiator=true and calls Initiate.","Check your connection setup so the correct peer initiates; the responder side should only call ProcessPacket.","Fix tests to create the machine with the initiator flag set to true when testing Initiate."],"exampleFix":"// before\nm := handshake.NewMachine(cs, false) // responder\npacket, err := m.Initiate(nil)\n// after\nm := handshake.NewMachine(cs, true) // initiator\npacket, err := m.Initiate(nil)","handlingStrategy":"type-guard","validationCode":"if !m.result.Initiator {\n    return errors.New(\"refusing to call Initiate on responder machine\")\n}","typeGuard":"func canInitiate(m *handshake.Machine) bool {\n    return m.Result().Initiator && !m.Failed()\n}","tryCatchPattern":"packet, err := m.Initiate(payload)\nif errors.Is(err, handshake.ErrInitiateOnResponder) {\n    // wrong role: switch to ProcessPacket-driven flow or rebuild as initiator\n}","preventionTips":["Track peer roles explicitly (initiator vs responder) in connection setup","Only call Initiate on machines constructed with isInitiator=true","Add unit tests asserting role before handshake initiation"],"tags":["handshake","state-machine","misuse"],"backgroundTag":"invalid-state-transition","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}