Skip to content

fix: handle case when no PCF is found in PCFSelection#219

Merged
Alonza0314 merged 1 commit intofree5gc:mainfrom
DBGR18:fix/1046
May 6, 2026
Merged

fix: handle case when no PCF is found in PCFSelection#219
Alonza0314 merged 1 commit intofree5gc:mainfrom
DBGR18:fix/1046

Conversation

@DBGR18
Copy link
Copy Markdown
Contributor

@DBGR18 DBGR18 commented May 5, 2026

fixing issue 1046

This pull request adds a safety check to the PCFSelection method in nrf_service.go to handle cases where no PCF instances are found, preventing potential nil pointer errors.

Error handling improvement:

  • Added a check to return an error if res is nil or if there are no PCF instances found in res.SearchResult.NfInstances within the PCFSelection method of nrf_service.go.

Copilot AI review requested due to automatic review settings May 5, 2026 13:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens SMF’s NRF consumer PCF discovery path by preventing a panic when NRF discovery returns no PCF instances (or a nil response), aligning PCF selection behavior with existing CHF selection handling.

Changes:

  • Added a guard in PCFSelection to return a clear error when the NRF discovery response is nil or contains zero PCF instances.
  • Prevented potential out-of-bounds / nil dereference when assigning SelectedPCFProfile.

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

@d11nn
Copy link
Copy Markdown
Contributor

d11nn commented May 5, 2026

@Alonza0314 LGTM

@Alonza0314 Alonza0314 merged commit ed13035 into free5gc:main May 6, 2026
9 of 10 checks passed
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.

4 participants