{"record":{"id":"ab4e1645e41cce00","repo":"gastownhall/beads","slug":"managed-ignore-observation-is-absent-or-invalid","errorCode":null,"errorMessage":"managed ignore observation is absent or invalid","messagePattern":"managed ignore observation is absent or invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/worktreeremove/policy.go","lineNumber":195,"sourceCode":"\tcase CurrentWorktree:\n\t\treturn Plan{}, fmt.Errorf(\"cannot remove the worktree containing the running command\")\n\tcase RegisteredTarget:\n\tdefault:\n\t\treturn Plan{}, fmt.Errorf(\"registered worktree target is absent or invalid\")\n\t}\n\tif facts.Registration != Present || facts.RegisteredPath == \"\" ||\n\t\tfacts.TargetDir != Present || facts.GitAdminDir != Present ||\n\t\tfacts.GitMarker != Present || facts.Head != Present {\n\t\treturn Plan{}, fmt.Errorf(\"registered worktree target is absent or invalid\")\n\t}\n\tif facts.CommonDir != Matched {\n\t\treturn Plan{}, fmt.Errorf(\"target common git directory does not match repository\")\n\t}\n\tif facts.Status != Clean && facts.Status != Dirty {\n\t\treturn Plan{}, fmt.Errorf(\"worktree cleanliness observation is absent or invalid\")\n\t}\n\tif facts.ManagedIgnore != IgnoreAbsent && facts.ManagedIgnore != IgnoreManaged {\n\t\treturn Plan{}, fmt.Errorf(\"managed ignore observation is absent or invalid\")\n\t}\n\tif (facts.ManagedIgnore == IgnoreManaged) != (facts.ManagedIgnoreEntry != \"\") {\n\t\treturn Plan{}, fmt.Errorf(\"managed ignore cleanup identity is absent or invalid\")\n\t}\n\tif request.Mode != Force {\n\t\tif facts.Status != Clean {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree contains modified, untracked, or ignored files\")\n\t\t}\n\t\tif facts.Comparator != ComparatorAvailable && facts.Comparator != ComparatorMissing && facts.Comparator != ComparatorNotRequired {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree comparison target observation is absent or invalid\")\n\t\t}\n\t\tif facts.Comparator != ComparatorAvailable {\n\t\t\treturn Plan{}, fmt.Errorf(\"cannot verify unpushed commits: no comparison target is available\")\n\t\t}\n\t\tif facts.Containment != Contained && facts.Containment != NotContained && facts.Containment != ContainmentNotRequired {\n\t\t\treturn Plan{}, fmt.Errorf(\"worktree containment observation is absent or invalid\")\n\t\t}\n\t\tif facts.Containment != Contained {","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/worktreeremove/policy.go#L177-L213","documentation":"Prepare rejects the request because facts.ManagedIgnore is neither IgnoreAbsent nor IgnoreManaged. The observation of whether this worktree has a beads/git-managed ignore entry is missing or invalid, so the library cannot decide whether to schedule ignore-file cleanup.","triggerScenarios":"Calling Prepare with a zero-value or out-of-range ManagedIgnore value, typically from an adapter that never inspected the managed ignore file.","commonSituations":"Custom adapters not reading the managed ignore file; tests constructing PrepareFacts without ManagedIgnore; enum drift after new IgnoreKind values were added.","solutions":["Set facts.ManagedIgnore to IgnoreManaged or IgnoreAbsent based on inspecting the managed ignore file","Fix the adapter so it always assigns a defined IgnoreKind even when the file is unreadable (use IgnoreAbsent only if truly absent)","In tests, add ManagedIgnore: worktreeremove.IgnoreAbsent"],"exampleFix":"// before\nfacts.ManagedIgnore = 0 // zero value, invalid\n// after\nfacts.ManagedIgnore = worktreeremove.IgnoreAbsent // or IgnoreManaged per observation","handlingStrategy":"validation","validationCode":"if facts.ManagedIgnore != worktreeremove.IgnoreAbsent && facts.ManagedIgnore != worktreeremove.IgnoreManaged {\n\treturn fmt.Errorf(\"managed-ignore state not observed\")\n}","typeGuard":"func ignoreObserved(k worktreeremove.IgnoreKind) bool {\n\treturn k == worktreeremove.IgnoreAbsent || k == worktreeremove.IgnoreManaged\n}","tryCatchPattern":"plan, err := worktreeremove.Prepare(req, facts)\nif err != nil && strings.Contains(err.Error(), \"managed ignore observation is absent\") {\n\treturn fmt.Errorf(\"inspect the managed ignore file before retrying: %w\", err)\n}","preventionTips":["Read the managed ignore file in the adapter and set a defined IgnoreKind","Treat unreadable ignore files as an explicit error, not a zero value","Add an enum completeness check to adapter unit tests"],"tags":["worktree","git","validation"],"backgroundTag":"incomplete-observations","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}