Skip to content

Commit

Permalink
fix: panic in schema watch (#2824)
Browse files Browse the repository at this point in the history
fixes: #2802
  • Loading branch information
stuartwdouglas authored Sep 25, 2024
1 parent d8af883 commit 93de931
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions frontend/cli/cmd_schema_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,34 @@ func (g *getSchemaCmd) Run(ctx context.Context, client ftlv1connect.ControllerSe
}
for resp.Receive() {
msg := resp.Msg()
module, err := schema.ModuleFromProto(msg.Schema)
if len(g.Modules) == 0 || remainingNames[msg.Schema.Name] {
if err != nil {
return fmt.Errorf("invalid module schema: %w", err)
}
fmt.Println(module)
delete(remainingNames, msg.Schema.Name)
}
if !msg.More {
missingNames := maps.Keys(remainingNames)
slices.Sort(missingNames)
if len(missingNames) > 0 {
if g.Watch {
fmt.Printf("missing modules: %s\n", strings.Join(missingNames, ", "))
} else {
return fmt.Errorf("missing modules: %s", strings.Join(missingNames, ", "))
switch resp.Msg().ChangeType {
case ftlv1.DeploymentChangeType_DEPLOYMENT_ADDED, ftlv1.DeploymentChangeType_DEPLOYMENT_CHANGED:
module, err := schema.ModuleFromProto(msg.Schema)
if len(g.Modules) == 0 || remainingNames[msg.Schema.Name] {
if err != nil {
return fmt.Errorf("invalid module schema: %w", err)
}
fmt.Println(module)
delete(remainingNames, msg.Schema.Name)
}
if !g.Watch {
break
if !msg.More {
missingNames := maps.Keys(remainingNames)
slices.Sort(missingNames)
if len(missingNames) > 0 {
if g.Watch {
fmt.Printf("missing modules: %s\n", strings.Join(missingNames, ", "))
} else {
return fmt.Errorf("missing modules: %s", strings.Join(missingNames, ", "))
}
}
if !g.Watch {
break
}
}
case ftlv1.DeploymentChangeType_DEPLOYMENT_REMOVED:
fmt.Printf("deployment %s removed\n", msg.DeploymentKey)
}

}
if err := resp.Err(); err != nil {
return resp.Err()
Expand Down

0 comments on commit 93de931

Please sign in to comment.