Merge pull request #322224 from microsoft/connor4312/sessionperm-realpath-flake

agentHost: fix flaky write auto-approval on Windows from native realpath
This commit is contained in:
Connor Peet
2026-06-20 10:41:19 -07:00
committed by GitHub
@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { realpath } from 'fs/promises';
import { homedir } from 'os';
import { match as globMatch, parse as globParse, type ParsedPattern } from '../../../base/common/glob.js';
import { untildify } from '../../../base/common/labels.js';
@@ -13,6 +12,7 @@ import { isMacintosh, isWindows } from '../../../base/common/platform.js';
import { extUriBiasedIgnorePathCase, normalizePath } from '../../../base/common/resources.js';
import { isDefined } from '../../../base/common/types.js';
import { URI } from '../../../base/common/uri.js';
import { Promises } from '../../../base/node/pfs.js';
import { localize } from '../../../nls.js';
import { ILogService } from '../../log/common/log.js';
import { platformSessionSchema } from '../common/agentHostSchema.js';
@@ -150,7 +150,7 @@ function assertPathIsSafe(fsPath: string, _isWindows = isWindows): void {
*/
async function resolveRealPathForNonexistent(fsPath: string): Promise<string> {
try {
return await realpath(fsPath);
return await Promises.realpath(fsPath);
} catch (e) {
if ((e as NodeJS.ErrnoException).code !== 'ENOENT') {
throw e;
@@ -166,7 +166,7 @@ async function resolveRealPathForNonexistent(fsPath: string): Promise<string> {
return fsPath;
}
try {
const resolved = await realpath(current);
const resolved = await Promises.realpath(current);
return path.join(resolved, ...tail);
} catch (e) {
const code = (e as NodeJS.ErrnoException).code;