{"record":{"id":"4f8b2a1805769ec7","repo":"hashicorp/nomad","slug":"windows-path-expansion-not-supported-on-this-platf","errorCode":null,"errorMessage":"Windows path expansion not supported on this platform","messagePattern":"Windows path expansion not supported on this platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/winsvc/path_nonwindows.go","lineNumber":17,"sourceCode":"// Copyright IBM Corp. 2015, 2026\n// SPDX-License-Identifier: BUSL-1.1\n\n//go:build !windows\n\npackage winsvc\n\nimport \"errors\"\n\nfunc NewWindowsPaths() WindowsPaths {\n\treturn &windowsPaths{}\n}\n\ntype windowsPaths struct{}\n\nfunc (w *windowsPaths) Expand(string) (string, error) {\n\treturn \"\", errors.New(\"Windows path expansion not supported on this platform\")\n}\n\nfunc (w *windowsPaths) CreateDirectory(string, bool) error {\n\treturn errors.New(\"Windows directory creation not supported on this platform\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/winsvc/path_nonwindows.go#L1-L23","documentation":"The non-Windows windowsPaths implementation of Expand always returns this error, since Windows-style environment/path expansion is meaningless off-Windows. It is a fail-fast stub for the cross-platform interface.","triggerScenarios":"Calling windowsPaths.Expand(path) (via the Paths interface) on a non-Windows platform; code that uses the Windows path helpers compiled for Linux/macOS.","commonSituations":"Shared code that expands service paths without checking GOOS; running Windows service provisioning logic on Unix.","solutions":["Use the platform-appropriate Paths implementation; expansion is only valid on Windows","Guard the call with runtime.GOOS == \"windows\" or a build-tagged abstraction","Use os.ExpandEnv or filepath utilities for portable path expansion on Unix","Confirm the process isn't mistakenly built to use windowsPaths on non-Windows"],"exampleFix":"// before\np, _ := winsvc.NewPaths() // windowsPaths on Linux\nout, err := p.Expand(\"%APPDATA%\\\\svc\")\n// after\nif runtime.GOOS != \"windows\" {\n  out = os.ExpandEnv(\"$HOME/.svc\")\n} else {\n  out, err = p.Expand(\"%APPDATA%\\\\svc\")\n}","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"windows\" {\n  expanded := os.ExpandEnv(rawPath)\n}","typeGuard":null,"tryCatchPattern":"out, err := paths.Expand(p)\nif err != nil {\n  out = os.ExpandEnv(p) // portable fallback\n}","preventionTips":["Gate winsvc path helpers behind GOOS checks or build tags","Use os.ExpandEnv/filepath for cross-platform expansion","Pick the correct Paths implementation per platform at startup"],"tags":["go","windows","platform","path"],"backgroundTag":"unsupported-platform-call","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}