fix(ngap): route remaining FetchRanUeContext lookups through nil-safe helper#732
Conversation
… helper omec-project#666 added findRanUeByRanNgapID(), which returns nil when the RANUENGAPID IE pointer is nil, and converted most procedure-code cases in FetchRanUeContext to use it. Three cases were left calling ran.RanUeFindByRanUeNgapID(rANUENGAPID.Value) directly: HandoverNotification, HandoverPreparation, and PDUSessionResourceModifyResponse. Their in-loop checks only catch a RANUENGAPID IE that is present with a nil value; if the IE is entirely absent from the message, rANUENGAPID stays nil and the .Value dereference panics. Route these three through findRanUeByRanNgapID() like the rest of the function. Signed-off-by: Vinod Patmanathan <vinod.patmanathan@forsway.com>
There was a problem hiding this comment.
Pull request overview
This pull request completes the migration in FetchRanUeContext to use the nil-safe findRanUeByRanNgapID() helper for RAN UE context lookup, preventing panics when RANUENGAPID is absent from malformed NGAP messages.
Changes:
- Updated
HandoverNotificationto usefindRanUeByRanNgapID()instead of dereferencingrANUENGAPID.Value. - Updated
HandoverPreparationto usefindRanUeByRanNgapID()instead of dereferencingrANUENGAPID.Value. - Updated
PDUSessionResourceModify(SuccessfulOutcome / response path) to usefindRanUeByRanNgapID()instead of dereferencingrANUENGAPID.Value.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Should we make this change across the codebase? There are other 20+ occurrences of this - ranUe = ran.RanUeFindByRanUeNgapID(rANUENGAPID.Value)
+ ranUe = findRanUeByRanNgapID(ran, rANUENGAPID) |
|
Agreed. It's worth doing across the codebase: beyond the 4 handlers in #731, there are 6 more that still panic on an absent ID IE (UplinkNasTransport, PDUSessionResourceReleaseResponse, HandoverCancel, NasNonDeliveryIndication, UERadioCapabilityInfoIndication, UEContextReleaseComplete). I'll do a sweep converting all the raw RanUeFindBy{Ran,AmfUe}NgapID(...Value) calls to the two helpers. |
|
Implemented in #731. Expanded from the original 4 handlers to all 10 that actually panic on a missing NGAP-ID IE. Full breakdown's in the PR description. |
Description
#666 introduced the nil-safe helper
findRanUeByRanNgapID()— it returnsnilwhen theRANUENGAPIDIE pointer isnilinstead of dereferencing.Value— and converted most procedure-code cases inFetchRanUeContextto use it. Three cases were missed and still callran.RanUeFindByRanUeNgapID(rANUENGAPID.Value)directly:HandoverNotificationHandoverPreparationPDUSessionResourceModify(Response)In each, the in-loop check only catches a
RANUENGAPIDIE that is present with a nil value. If the IE is entirely absent from the message,rANUENGAPIDstaysniland the subsequent.Valuedereference panics the AMF — the same malformed-input crash class #666 set out to close.This routes those three lookups through
findRanUeByRanNgapID()like the rest of the function, makingFetchRanUeContextuniformly nil-safe.Testing
go build ./...,go vet ./...,go test ./...all passgolangci-lint run --new-from-rev=main→0 issues.gofmtclean