{"record":{"id":"7068516e0ea3f4ea","repo":"chenhg5/cc-connect","slug":"sudo-is-not-supported-on-windows","errorCode":null,"errorMessage":"sudo is not supported on Windows","messagePattern":"sudo is not supported on Windows","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/runas_windows.go","lineNumber":47,"sourceCode":"// it before we get here) and delegates to exec.CommandContext.\nfunc BuildSpawnCommand(ctx context.Context, _ SpawnOptions, name string, args ...string) *exec.Cmd {\n\treturn exec.CommandContext(ctx, name, args...)\n}\n\n// FilterEnvForSpawn on Windows is a no-op pass-through.\nfunc FilterEnvForSpawn(env []string, _ SpawnOptions) []string { return env }\n\n// SudoRunner is a stub interface on Windows for API compatibility.\ntype SudoRunner interface {\n\tRun(ctx context.Context, args ...string) ([]byte, error)\n}\n\n// ExecSudoRunner is a stub on Windows.\ntype ExecSudoRunner struct{}\n\n// Run always fails on Windows.\nfunc (ExecSudoRunner) Run(ctx context.Context, args ...string) ([]byte, error) {\n\treturn nil, errors.New(\"sudo is not supported on Windows\")\n}\n\n// VerifyRunAsUserCheap always fails on Windows.\nfunc VerifyRunAsUserCheap(_ context.Context, _ SudoRunner, runAsUser string) error {\n\tif runAsUser == \"\" {\n\t\treturn nil\n\t}\n\treturn errors.New(\"run_as_user is not supported on Windows\")\n}\n","sourceCodeStart":29,"sourceCodeEnd":57,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/runas_windows.go#L29-L57","documentation":"ExecSudoRunner.Run is a Windows stub: sudo-based run_as_user isolation is only implemented for Unix-like systems, so any invocation on Windows returns this error unconditionally. It exists to keep the package compilable on Windows while making the unsupportedness explicit at runtime.","triggerScenarios":"Calling any SudoRunner-based path (isolation probe, preflight, session spawn with run_as_user) on a Windows build of cc-connect (core/runas_windows.go:47).","commonSituations":"Running cc-connect.exe with run_as_user configured; CI matrix builds executing Unix-targeted tests on windows-latest; developers porting tooling that assumed a POSIX host.","solutions":["Run cc-connect on Linux/macOS where sudo isolation is supported.","Remove run_as_user configuration on Windows hosts so sudo paths are never exercised.","Gate the isolation feature on runtime.GOOS and skip with a warning on windows."],"exampleFix":"// before\nout, err := runner.Run(ctx, \"-n\", \"-iu\", user, \"--\", \"/usr/bin/true\")\n// after\nif runtime.GOOS == \"windows\" {\n    slog.Warn(\"run_as_user isolation is not supported on Windows; skipping\")\n    return nil\n}\nout, err := runner.Run(ctx, \"-n\", \"-iu\", user, \"--\", \"/usr/bin/true\")","handlingStrategy":"validation","validationCode":"if runtime.GOOS == \"windows\" {\n    // skip or reject run_as_user configuration before any sudo call\n}","typeGuard":null,"tryCatchPattern":"out, err := runner.Run(ctx, args...)\nif err != nil && runtime.GOOS == \"windows\" {\n    slog.Warn(\"sudo unsupported on this platform\", \"err\", err)\n    return nil, errSkipIsolation\n}","preventionTips":["Do not configure run_as_user on Windows deployments.","Feature-flag sudo isolation per OS in config validation.","Add build-tag-aware tests so CI on Windows skips sudo paths."],"tags":["windows","platform","sudo","unsupported"],"backgroundTag":"unsupported-platform","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}