Skip to content

fix(ngap): route remaining FetchRanUeContext lookups through nil-safe helper#732

Merged
gab-arrobo merged 1 commit into
omec-project:mainfrom
donivtech:fix/fetchranuecontext-nil-safe-lookup
Jun 25, 2026
Merged

fix(ngap): route remaining FetchRanUeContext lookups through nil-safe helper#732
gab-arrobo merged 1 commit into
omec-project:mainfrom
donivtech:fix/fetchranuecontext-nil-safe-lookup

Conversation

@donivtech

Copy link
Copy Markdown
Contributor

Description

#666 introduced the nil-safe helper findRanUeByRanNgapID() — it returns nil when the RANUENGAPID IE pointer is nil instead of dereferencing .Value — and converted most procedure-code cases in FetchRanUeContext to use it. Three cases were missed and still call ran.RanUeFindByRanUeNgapID(rANUENGAPID.Value) directly:

  • HandoverNotification
  • HandoverPreparation
  • PDUSessionResourceModify (Response)

In each, the in-loop check only catches a RANUENGAPID IE that is present with a nil value. If the IE is entirely absent from the message, rANUENGAPID stays nil and the subsequent .Value dereference 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, making FetchRanUeContext uniformly nil-safe.

Testing

  • go build ./..., go vet ./..., go test ./... all pass
  • golangci-lint run --new-from-rev=main0 issues.
  • gofmt clean

… 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>
@donivtech donivtech requested a review from a team June 25, 2026 09:21
@gab-arrobo gab-arrobo requested a review from Copilot June 25, 2026 15:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HandoverNotification to use findRanUeByRanNgapID() instead of dereferencing rANUENGAPID.Value.
  • Updated HandoverPreparation to use findRanUeByRanNgapID() instead of dereferencing rANUENGAPID.Value.
  • Updated PDUSessionResourceModify (SuccessfulOutcome / response path) to use findRanUeByRanNgapID() instead of dereferencing rANUENGAPID.Value.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gab-arrobo gab-arrobo merged commit f2beb8f into omec-project:main Jun 25, 2026
12 checks passed
@gab-arrobo

Copy link
Copy Markdown
Contributor

Should we make this change across the codebase? There are other 20+ occurrences of this

-			ranUe = ran.RanUeFindByRanUeNgapID(rANUENGAPID.Value)
+			ranUe = findRanUeByRanNgapID(ran, rANUENGAPID)

@donivtech

Copy link
Copy Markdown
Contributor Author

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.

@donivtech

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants