fix: gate Schannel/gitconfig probe to Windows only - #31
Merged
Conversation
On macOS and Linux, `IsSchannelSelectedInGitConfig()` P/Invokes `GetPrivateProfileString` from `kernel32`. That symbol is not exported by the kernel32 shim dylib, so every startup that finds `~/.gitconfig` throws an `EntryPointNotFoundException` which is caught, logged via `Trace.TraceError`, and surfaced in Studio logs as an [ERROR] burst. Git functionality is unaffected (the exception forces `useSchannel = false`, which is the only correct value on non-Windows anyway — no schannel binaries ship for osx/linux RIDs), but the log noise is confusing and masks real errors. `GetPrivateProfileString` and Schannel are Windows-only concepts. Guard the entire probe with `RuntimeInformation.IsOSPlatform(Windows)` so the gitconfig read and the env-var env-var footgun (`UIPATH_STUDIO_GIT_USE_SCHANNEL` forcing a missing dylib) are both inert on mac/Linux. Windows behavior is byte-for-byte unchanged: the `&&` short-circuits into the original expression on Windows. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
andrei-balint
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS and Linux, Studio logs fill with
[ERROR]bursts during startup / first git access:Git functionality is not affected — the exception is caught, forces
useSchannel = false(the only correct answer on non-Windows), and the plainliblibgit2.dylibis loaded as intended. The problem is pure log noise that masks real errors.Root cause
IsSchannelSelectedInGitConfig()P/InvokesGetPrivateProfileStringfromkernel32to read~/.gitconfigas an INI file. On macOS, thekernel32shim dylib is found and loaded (it is registered viaXpfBootstrap.OnResolvingUnmanagedDll), but the shim does not exportGetPrivateProfileString→EntryPointNotFoundExceptionon every call.The function's sole purpose is to decide whether to load the
libgit2_schannelvariant. Schannel is a Windows-only TLS stack (SSPI); no schannel binaries ship forosx-*orlinux-*RIDs. The probe is therefore meaningless on non-Windows and has no valid non-false result.Why gating is the correct fix (not implementing the P/Invoke)
Implementing
GetPrivateProfileStringin the shim would make the read succeed, but atrueresult (sslBackend = schannelin.gitconfig, plausible via dotfiles synced from Windows) would setlibraryName = "libgit2_schannel"and callSetHttpBackend(Schannel)— then the loader would hunt forliblibgit2_schannel.dylib, which does not exist, breaking git entirely for those users. The unconditionally-false answer produced today by the exception is the only correct mac/Linux answer; gating the probe makes that explicit.Fix
One-line guard in
NativeMethods.cs:95:&&short-circuits into the original expression — byte-for-byte identical behaviour.useSchannelisfalseimmediately — no gitconfig probe, nokernel32P/Invoke, no error, no risk of the broken schannel-load path. Also neutralises theUIPATH_STUDIO_GIT_USE_SCHANNELfootgun on non-Windows (setting that env var would previously trigger a schannel load attempt for a dylib that doesn't exist).IsOSPlatform(Windows)is intentionally used here (not!IsWindows()): bothGetPrivateProfileStringand Schannel are genuinely Windows-specific, not merely non-Linux concerns. There is no equivalent backend to gate on for macOS separately.Test plan
GetPrivateProfileString/EntryPointNotFoundExceptionlines in_dotnet.log~/.gitconfigprobe work as beforeFollow-up
After this package is published, bump
LibGit2Sharp.UiPathinStudio/Directory.Build.targetsfrom1.9.1-v6to the new version. A plain v6→v7 bump does not fix this — the gate must be in the package.🤖 Generated with Claude Code