{"record":{"id":"ec28b765695eb1fd","repo":"netbirdio/netbird","slug":"rollback-rule-s-w","errorCode":null,"errorMessage":"rollback rule %s: %w","messagePattern":"rollback rule (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/iptables/router_linux.go","lineNumber":871,"sourceCode":"\n// cleanupFailedDNATAdd removes the bookkeeping written by a partially applied\n// AddDNATRule before rolling back the kernel rules, so no entries remain that\n// never got a forwarding refcount. rollbackRules re-adds entries it failed to\n// remove from the kernel.\nfunc (r *router) cleanupFailedDNATAdd(rules map[string]ruleInfo) {\n\tfor key := range rules {\n\t\tdelete(r.rules, key)\n\t}\n\tif err := r.rollbackRules(rules); err != nil {\n\t\tlog.Errorf(\"rollback failed: %v\", err)\n\t}\n}\n\nfunc (r *router) rollbackRules(rules map[string]ruleInfo) error {\n\tvar merr *multierror.Error\n\tfor key, ruleInfo := range rules {\n\t\tif err := r.iptablesClient.DeleteIfExists(ruleInfo.table, ruleInfo.chain, ruleInfo.rule...); err != nil {\n\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"rollback rule %s: %w\", key, err))\n\t\t\t// On rollback error, add to rules map for next cleanup\n\t\t\tr.rules[key] = ruleInfo.rule\n\t\t}\n\t}\n\tif merr != nil {\n\t\tr.updateState()\n\t}\n\treturn nberrors.FormatErrorOrNil(merr)\n}\n\nfunc (r *router) DeleteDNATRule(rule firewall.Rule) error {\n\truleKey := rule.ID()\n\n\t_, hadDNAT := r.rules[ruleKey+dnatSuffix]\n\t_, hadSNAT := r.rules[ruleKey+snatSuffix]\n\t_, hadFWD := r.rules[ruleKey+fwdSuffix]\n\tif !hadDNAT && !hadSNAT && !hadFWD {\n\t\treturn nil","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/iptables/router_linux.go#L853-L889","documentation":"Error \"rollback rule %s: %w\" thrown in netbirdio/netbird.","triggerScenarios":"Thrown at client/firewall/iptables/router_linux.go:871 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":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}