Skip to content

Commit f48b01d

Browse files
twishabansalgemini-code-assist[bot]Yuan325
authored
fix(server): return errors instead of panicking in InitializeConfigs (#3397)
## Description `InitializeOfflineConfigs` previously called `panic(err)` when the instrumentation or logger could not be retrieved from the context. This changes those to graceful error returns (`return nil, nil, fmt.Errorf(...)`) so callers (e.g. `skills-generate`) get a clean error instead of a crash. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
1 parent 6ffbdec commit f48b01d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎internal/server/server.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func InitializeConfigs(ctx context.Context, cfg ServerConfig) (
8989
ctx = util.WithUserAgent(ctx, metadataStr)
9090
instrumentation, err := util.InstrumentationFromContext(ctx)
9191
if err != nil {
92-
panic(err)
92+
return nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get instrumentation from context: %w", err)
9393
}
9494

9595
l, err := util.LoggerFromContext(ctx)
9696
if err != nil {
97-
panic(err)
97+
return nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get logger from context: %w", err)
9898
}
9999

100100
// initialize and validate the sources from configs
@@ -274,12 +274,12 @@ func InitializeOfflineConfigs(ctx context.Context, cfg ServerConfig) (
274274
) {
275275
instrumentation, err := util.InstrumentationFromContext(ctx)
276276
if err != nil {
277-
panic(err)
277+
return nil, nil, fmt.Errorf("failed to get instrumentation from context: %w", err)
278278
}
279279

280280
l, err := util.LoggerFromContext(ctx)
281281
if err != nil {
282-
panic(err)
282+
return nil, nil, fmt.Errorf("failed to get logger from context: %w", err)
283283
}
284284

285285
toolsMap, err := initializeTools(ctx, cfg, instrumentation, l)

0 commit comments

Comments
 (0)