Skip to content

Fix nil-pointer dereference when mapping WebSub API channels in mapWebSubAPIModelToAPI #1995

@coderabbitai

Description

@coderabbitai

Summary

In platform-api/src/internal/service/websub_api.go, the mapWebSubAPIModelToAPI function (line 417) dereferences the pointer returned by mapWebSubChannelsModelToAPI, which returns nil when the input channel map is empty. This causes a nil-pointer dereference panic at runtime when a WebSub API has no channels.

Location

  • File: platform-api/src/internal/service/websub_api.go
  • Function: mapWebSubAPIModelToAPI
  • Line: 417

Steps to Reproduce

Retrieve a WebSub API that was created or stored with an empty channels map. The Get, List, or Update return path will trigger the panic via mapWebSubAPIModelToAPI.

Expected Behavior

The mapping should handle an empty or nil channel map gracefully and return an empty (non-nil) value for Channels.

Related

Reported by @senthuran16.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions