{"record":{"id":"da02b68fefd05896","repo":"d2lang/d2","slug":"no-actors-declared-in-sequence-diagram","errorCode":null,"errorMessage":"no actors declared in sequence diagram","messagePattern":"no actors declared in sequence diagram","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2layouts/d2sequence/sequence_diagram.go","lineNumber":109,"sourceCode":"\t\t\tqueue := []*d2graph.Object{obj}\n\t\t\t// Groups may have more nested groups\n\t\t\tfor len(queue) > 0 {\n\t\t\t\tcurr := queue[0]\n\t\t\t\tcurr.LabelPosition = go2.Pointer(label.InsideTopLeft.String())\n\t\t\t\tgroups = append(groups, curr)\n\t\t\t\tqueue = queue[1:]\n\t\t\t\tqueue = append(queue, curr.ChildrenArray...)\n\t\t\t}\n\t\t} else {\n\t\t\tactors = append(actors, obj)\n\t\t\tif obj.IsSequenceDiagram() {\n\t\t\t\treturn nil, fmt.Errorf(\"actors in sequence diagrams cannot themselves be sequence diagrams: %s\", obj.AbsID())\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(actors) == 0 {\n\t\treturn nil, errors.New(\"no actors declared in sequence diagram\")\n\t}\n\n\tsd := &sequenceDiagram{\n\t\tmessages:        messages,\n\t\tactors:          actors,\n\t\tgroups:          groups,\n\t\tspans:           nil,\n\t\tnotes:           nil,\n\t\tlifelines:       nil,\n\t\tobjectRank:      make(map[*d2graph.Object]int),\n\t\tfirstMessage:    make(map[*d2graph.Object]*d2graph.Edge),\n\t\tlastMessage:     make(map[*d2graph.Object]*d2graph.Edge),\n\t\tactorXStep:      make([]float64, len(actors)-1),\n\t\tyStep:           MIN_MESSAGE_DISTANCE,\n\t\tmaxActorHeight:  0.,\n\t\tverticalIndices: make(map[string]int),\n\t}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2layouts/d2sequence/sequence_diagram.go#L91-L127","documentation":"The sequence diagram layout requires at least one actor (top-level participant shapes). If the graph contains no shapes that qualify as actors, newSequenceDiagram cannot build a diagram and returns this error.","triggerScenarios":"Applying layout: seq (near or with d2layout sequence engine) to a graph where the `actors` slice is empty — e.g. a diagram with only edges, or all objects are groups/containers of sequence diagrams.","commonSituations":"Setting `layout: seq` globally but the board contains a non-sequence subgraph; an empty or edge-only diagram; nested sequence diagrams filtered out by the 'cannot themselves be sequence diagrams' rule leaving zero actors.","solutions":["Declare at least two participant shapes in the sequence diagram scope.","Ensure the diagram using seq layout actually contains participant objects (not just connections).","If seq is set globally, scope it only to the intended nested diagram via near/layout attributes, or switch the board's layout engine to elk/dae for non-sequence boards.","Check that participants aren't misclassified (e.g. marked as containers/groups)."],"exampleFix":"// before\nvars: { d2-config: { layout-engine: seq } }\nx -> y\n// after\nvars: { d2-config: { layout-engine: seq } }\na: A\nb: B\na -> b","handlingStrategy":"validation","validationCode":"actors := 0\nfor _, o := range g.Objects { if isSequenceActor(o) { actors++ } }\nif actors == 0 { /* skip seq layout or add participants */ }","typeGuard":"func hasSeqActors(g *d2graph.Graph) bool {\n  for _, o := range g.Objects { if o.InnerSequenceDiagram() == nil { return true } }\n  return false\n}","tryCatchPattern":"if err := layoutSequenceDiagram(g); err != nil && strings.Contains(err.Error(), \"no actors\") {\n  // fall back to the default layout engine\n}","preventionTips":["Only apply layout: seq to boards containing participant shapes.","Scope seq layout with near/layout attributes rather than globally.","Add explicit actor declarations to every sequence diagram."],"tags":["d2","sequence-diagram","layout"],"backgroundTag":"missing-layout-participants","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}