cloudwego / cloudwego/kitex

fix: RegisterService should return errors instead of panic

Open Beginner friendly
#1,981 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
8k
Forks
918
Avg merge
1d 13h
Merged PRs (30d)
7

Description

## Problem

The RegisterService method in server/server.go declares error in its return signature but uses panic() for all parameter validation errors instead of returning errors properly.

### Current Behavior

The method uses panic() for validation errors, violating Go error handling best practices.

### Expected Behavior

The method should return errors via the declared error return value.

### Proposed Fix

Replace panic() calls with return errors.New(...) to match the method's error return contract.

Contributor guide

Open the contributing guide

Research direction

Start in server/server.go at the RegisterService method and inspect each parameter-validation path. Replace the validation panics with returned errors, then verify that invalid inputs produce errors through the declared return value rather than panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.