{"record":{"id":"8023452ed22cf39f","repo":"d2lang/d2","slug":"object-s-has-attribute-top-and-or-left-set","errorCode":null,"errorMessage":"Object \"%s\" has attribute \"top\" and/or \"left\" set, but layout engine \"%s\" does not support locked positions. See https://d2lang.com/tour/layouts/#layout-specific-functionality for more.","messagePattern":"Object \"(.+?)\" has attribute \"top\" and/or \"left\" set, but layout engine \"(.+?)\" does not support locked positions\\. See https://d2lang\\.com/tour/layouts/#layout-specific-functionality for more\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2plugin/plugin_features.go","lineNumber":41,"sourceCode":"\n// When this is true, the plugin also implements RoutingPlugin interface to route edges\nconst ROUTES_EDGES PluginFeature = \"routes_edges\"\n\nfunc FeatureSupportCheck(info *PluginInfo, g *d2graph.Graph) error {\n\t// Older version of plugin. Skip checking.\n\tif info.Features == nil {\n\t\treturn nil\n\t}\n\n\tfeatureMap := make(map[PluginFeature]struct{}, len(info.Features))\n\tfor _, f := range info.Features {\n\t\tfeatureMap[f] = struct{}{}\n\t}\n\n\tfor _, obj := range g.Objects {\n\t\tif obj.Top != nil || obj.Left != nil {\n\t\t\tif _, ok := featureMap[TOP_LEFT]; !ok {\n\t\t\t\treturn fmt.Errorf(`Object \"%s\" has attribute \"top\" and/or \"left\" set, but layout engine \"%s\" does not support locked positions. See https://d2lang.com/tour/layouts/#layout-specific-functionality for more.`, obj.AbsID(), info.Name)\n\t\t\t}\n\t\t}\n\t\tif (obj.WidthAttr != nil || obj.HeightAttr != nil) &&\n\t\t\tlen(obj.ChildrenArray) > 0 && !obj.IsGridDiagram() {\n\t\t\tif _, ok := featureMap[CONTAINER_DIMENSIONS]; !ok {\n\t\t\t\treturn fmt.Errorf(`Object \"%s\" has attribute \"width\" and/or \"height\" set, but layout engine \"%s\" does not support dimensions set on containers. See https://d2lang.com/tour/layouts/#layout-specific-functionality for more.`, obj.AbsID(), info.Name)\n\t\t\t}\n\t\t}\n\n\t\tif obj.NearKey != nil {\n\t\t\t_, isKey := g.Root.HasChild(d2graph.Key(obj.NearKey))\n\t\t\tif isKey {\n\t\t\t\tif _, ok := featureMap[NEAR_OBJECT]; !ok {\n\t\t\t\t\treturn fmt.Errorf(`Object \"%s\" has \"near\" set to another object, but layout engine \"%s\" only supports constant values for \"near\". See https://d2lang.com/tour/layouts/#layout-specific-functionality for more.`, obj.AbsID(), info.Name)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2plugin/plugin_features.go#L23-L59","documentation":"FeatureSupportCheck verifies the selected layout engine supports the features actually used by the graph. This error is thrown when an object has top/left set (locked position) but the layout engine did not declare the TOP_LEFT feature.","triggerScenarios":"A graph object has obj.Top or obj.Left set while the chosen layout engine's feature map lacks TOP_LEFT.","commonSituations":"Using a simple layout engine (e.g. dagre) after authoring a diagram for ELK with locked positions, or explicitly pinning x.y near/top/left with an unsupported engine.","solutions":["Switch to a layout engine that supports locked positions (e.g. ELK)","Remove the top/left attributes from the objects","Pin the object near a constant value like near-top-center instead"],"exampleFix":"// before\nx.near: top-left\n// after\nnear-top-center: { near: top-center } // or switch to elk layout","handlingStrategy":"validation","validationCode":"for _, obj := range g.Objects {\n\tif (obj.Top != nil || obj.Left != nil) && engineName != \"elk\" {\n\t\t// remove top/left or switch engine before layout\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := engine.FeatureSupportCheck(ctx, g); err != nil {\n\treturn fmt.Errorf(\"layout feature unsupported: %w\", err)\n}","preventionTips":["Run FeatureSupportCheck before Layout","Only pin top/left with ELK","Document per-engine feature limits in your pipeline"],"tags":["layout","feature-check","d2"],"backgroundTag":"layout-feature-unsupported","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}