Skip to content

Commit dff2696

Browse files
committed
don't return nextlevel for components at max level, more error checking when fetching service
1 parent 0337615 commit dff2696

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/cmd/root.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type serializedCheckResultsByLevel struct {
8888
type serializedCheckResults struct {
8989
ByLevel []serializedCheckResultsByLevel
9090
CurrentLevel serializedLevel
91-
NextLevel serializedLevel
91+
NextLevel *serializedLevel
9292
}
9393

9494
// newToolResult creates a CallToolResult for the passed object handling any json marshaling errors
@@ -455,6 +455,9 @@ var rootCmd = &cobra.Command{
455455
if err != nil {
456456
return nil, err
457457
}
458+
if service.Id == "" {
459+
return nil, fmt.Errorf("service with id %s not found", req.Params.Arguments["serviceId"].(string))
460+
}
458461

459462
stats, err := service.GetServiceStats(client)
460463
if err != nil {
@@ -466,10 +469,12 @@ var rootCmd = &cobra.Command{
466469
Alias: stats.Rubric.Level.Alias,
467470
Index: stats.Rubric.Level.Index,
468471
},
469-
NextLevel: serializedLevel{
472+
}
473+
if stats.Rubric.CheckResults.NextLevel.Level.Alias != "" {
474+
result.NextLevel = &serializedLevel{
470475
Alias: stats.Rubric.CheckResults.NextLevel.Level.Alias,
471476
Index: stats.Rubric.CheckResults.NextLevel.Level.Index,
472-
},
477+
}
473478
}
474479

475480
for _, checkResultsByLevel := range stats.Rubric.CheckResults.ByLevel.Nodes {

0 commit comments

Comments
 (0)