{"record":{"id":"9b1251eeec70beb2","repo":"OpenNHP/opennhp","slug":"ebpf-functionality-is-only-supported-on-linux-cur-9b1251","errorCode":null,"errorMessage":"eBPF functionality is only supported on Linux, current platform is not Linux","messagePattern":"eBPF functionality is only supported on Linux, current platform is not Linux","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/utils/ebpf/ebpf_other.go","lineNumber":7,"sourceCode":"//go:build !linux\n\npackage ebpf\n\nimport \"fmt\"\n\nvar ErrEBPFSupportedOnlyOnLinux = fmt.Errorf(\"eBPF functionality is only supported on Linux, current platform is not Linux\")\n\nfunc getBootTimeNanos() (uint64, error) {\n\tttlSec := 1222222222222\n\treturn uint64(ttlSec), ErrEBPFSupportedOnlyOnLinux\n}\n","sourceCodeStart":1,"sourceCodeEnd":13,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/utils/ebpf/ebpf_other.go#L1-L13","documentation":"ErrEBPFSupportedOnlyOnLinux is a sentinel error declared in the build-tagged file ebpf_other.go (//go:build !linux). On any non-Linux platform, EbpfEngineLoad and getBootTimeNanos return this error because the eBPF implementation only compiles/works on Linux. It is a deliberate platform guard, not a runtime fault.","triggerScenarios":"Calling EbpfEngineLoad(dirPath, logLevel, acId) or getBootTimeNanos on macOS/Windows (or any GOOS != linux) build; importing the endpoints/ac/ebpf package and starting eBPF-based access control on a dev laptop.","commonSituations":"Developers running nhp-ac locally on macOS for debugging; CI on non-Linux runners; forgetting that ebpf features are silently stubbed out via build tags.","solutions":["Run the component on Linux (the only supported platform for eBPF features)","Guard eBPF startup with runtime.GOOS check and skip/disable the feature gracefully","Use a Linux VM/container for local development","If the error appears on Linux, verify build tags didn't pick ebpf_other.go (wrong GOOS at build time)"],"exampleFix":"// before\nif err := ebpf.EbpfEngineLoad(dir, logLevel, acId); err != nil { log.Fatal(err) }\n// after\nif err := ebpf.EbpfEngineLoad(dir, logLevel, acId); err != nil {\n    if errors.Is(err, ebpf.ErrEBPFSupportedOnlyOnLinux) {\n        log.Warn(\"eBPF disabled: unsupported platform\")\n        return nil\n    }\n    return err\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"linux\" { return ebpf.ErrEBPFSupportedOnlyOnLinux } // guard before loading","typeGuard":"func ebpfSupported() bool { return runtime.GOOS == \"linux\" }","tryCatchPattern":"if err := EbpfEngineLoad(dir, lvl, id); err != nil { if errors.Is(err, ErrEBPFSupportedOnlyOnLinux) { disableEbpfGracefully(); return nil }; return err }","preventionTips":["Gate eBPF init behind runtime.GOOS == \"linux\"","Treat ErrEBPFSupportedOnlyOnLinux as a feature-disable signal, not a crash","Use errors.Is against the sentinel rather than string matching","Build/test on Linux CI for eBPF paths"],"tags":["ebpf","platform","linux","build-tags"],"backgroundTag":"unsupported-platform","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}