fix(controlplanestore): refuse workflow writes that drop a workflow an intake route names (#1962)
This commit is contained in:
2 files changed
+27
-2
No files matched your search
@@ -39,7 +39,29 @@ func (s *Server) checkIntakeRoutes(ctx context.Context, orgID string, value []by
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
collection, err := workflow.DecodeDefinitionCollection(stored.Value, s.steps)
|
||||
return s.checkRoutesDefined(routes, stored.Value)
|
||||
}
|
||||
|
||||
// checkRoutesDefinedBy refuses a workflow definitions write that removes a
|
||||
// workflow the org's intake routes still name, which would park every issue
|
||||
// matching that route at pin time.
|
||||
func (s *Server) checkRoutesDefinedBy(ctx context.Context, orgID string, definitions []byte) error {
|
||||
stored, err := s.resource(ctx, orgID, IntakeRoutesKind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var routes workflow.IntakeRoutes
|
||||
if err := json.Unmarshal(stored.Value, &routes); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(routes.Rules) == 0 && routes.Default == "" {
|
||||
return nil
|
||||
}
|
||||
return s.checkRoutesDefined(routes, definitions)
|
||||
}
|
||||
|
||||
func (s *Server) checkRoutesDefined(routes workflow.IntakeRoutes, definitions []byte) error {
|
||||
collection, err := workflow.DecodeDefinitionCollection(definitions, s.steps)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -215,7 +215,10 @@ func (s *Server) checkOrgWrite(ctx context.Context, orgID, kind string, value []
|
||||
case ModelAliasesKind:
|
||||
return s.checkAliasWrite(ctx, orgID, value)
|
||||
case WorkflowDefinitionsKind:
|
||||
return s.checkModelAliases(ctx, orgID, value)
|
||||
if err := s.checkModelAliases(ctx, orgID, value); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.checkRoutesDefinedBy(ctx, orgID, value)
|
||||
case IntakeRoutesKind:
|
||||
return s.checkIntakeRoutes(ctx, orgID, value)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user