{"record":{"id":"2f289973b36fb4c1","repo":"d2lang/d2","slug":"object-s-has-attribute-width-and-or-height","errorCode":null,"errorMessage":"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.","messagePattern":"Object \"(.+?)\" has attribute \"width\" and/or \"height\" set, but layout engine \"(.+?)\" does not support dimensions set on containers\\. 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":47,"sourceCode":"\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}\n\tif _, ok := featureMap[DESCENDANT_EDGES]; !ok {\n\t\tfor _, e := range g.Edges {\n\t\t\t// descendant edges are ok in sequence diagrams\n\t\t\tif e.Src.OuterSequenceDiagram() != nil || e.Dst.OuterSequenceDiagram() != nil {\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2plugin/plugin_features.go#L29-L65","documentation":"FeatureSupportCheck rejects graphs where a container object has explicit width/height set, but the layout engine did not declare the CONTAINER_DIMENSIONS feature. Engines that lay out containers automatically cannot honor forced container dimensions.","triggerScenarios":"An object with children (a container, non-grid) has WidthAttr or HeightAttr set and the engine lacks CONTAINER_DIMENSIONS.","commonSituations":"Setting explicit sizes on boxes that contain other boxes while using dagre; diagrams authored for ELK reused with another engine.","solutions":["Remove width/height from containers and let the engine size them","Switch to a layout engine supporting container dimensions (e.g. ELK)","Convert the container to a grid diagram (grid-rows/grid-columns), which is exempt"],"exampleFix":"// before\ncontainer: { width: 500; a; b }\n// after\ncontainer: { a; b } // or use layout: elk","handlingStrategy":"validation","validationCode":"for _, obj := range g.Objects {\n\tif (obj.WidthAttr != nil || obj.HeightAttr != nil) && len(obj.ChildrenArray) > 0 && !obj.IsGridDiagram() && engineName != \"elk\" {\n\t\t// strip width/height or switch engine\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := engine.FeatureSupportCheck(ctx, g); err != nil {\n\treturn fmt.Errorf(\"container dimensions unsupported: %w\", err)\n}","preventionTips":["Avoid explicit sizes on containers unless using ELK","Prefer grid layouts for fixed-size containers","Call FeatureSupportCheck in CI for authored diagrams"],"tags":["layout","feature-check","dimensions"],"backgroundTag":"layout-feature-unsupported","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}