{"record":{"id":"09874ead86291a6a","repo":"goharbor/harbor","slug":"cannot-add-child-to-non-directory-node","errorCode":null,"errorMessage":"cannot add child to non-directory node","messagePattern":"cannot add child to non-directory node","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/controller/artifact/processor/cnai/parser/util.go","lineNumber":141,"sourceCode":"\t\tType: TypeFile,\n\t\tSize: size,\n\t}\n}\n\nfunc NewDirectory(name string) *FileNode {\n\treturn &FileNode{\n\t\tName:     name,\n\t\tType:     TypeDirectory,\n\t\tChildren: make(map[string]*FileNode),\n\t}\n}\n\nfunc (root *FileNode) AddChild(child *FileNode) error {\n\troot.mu.Lock()\n\tdefer root.mu.Unlock()\n\n\tif root.Type != TypeDirectory {\n\t\treturn fmt.Errorf(\"cannot add child to non-directory node\")\n\t}\n\n\troot.Children[child.Name] = child\n\treturn nil\n}\n\nfunc (root *FileNode) GetChild(name string) (*FileNode, bool) {\n\troot.mu.RLock()\n\tdefer root.mu.RUnlock()\n\n\tchild, ok := root.Children[name]\n\treturn child, ok\n}\n\nfunc (root *FileNode) AddNode(path string, size int64, isDir bool) (*FileNode, error) {\n\tpath = filepath.Clean(path)\n\tparts := strings.Split(path, string(filepath.Separator))\n","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/controller/artifact/processor/cnai/parser/util.go#L123-L159","documentation":"Error \"cannot add child to non-directory node\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/controller/artifact/processor/cnai/parser/util.go:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}