Fix "Path too long" error in Kiota code generation #1164
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.
This PR fixes an issue where generating a Kiota API client with deeply nested paths fails with a "Could not find a part of the path" error on Windows systems due to path length limitations.
Changes
SafeReadAllLines
method toFileHelper.cs
that handles long file paths with multiple fallback strategiesCSharpFileMerger.cs
to use the new robust file reading methodImplementation Details
When file paths become too long (exceeding Windows' 260 character limit), standard file operations fail with path-related exceptions. The new
SafeReadAllLines
method first tries the normalFile.ReadAllLines
method, and if that fails due to path length issues, falls back to stream-based file reading that's more resilient to long paths.The solution makes minimal changes to the codebase, targeting only the specific file reading operations that were failing during the Kiota code generation process.
Fixes #1122.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
crl3.digicert.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)crl4.digicert.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj
(dns block)ocsp.digicert.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj
(dns block)petstore.swagger.io
/usr/lib/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/apiclientcodegen/apiclientcodegen/src/Core/ApiClientCodeGen.Core.Tests/bin/Debug/net8.0/ApiClientCodeGen.Core.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/apiclientcodegen/apiclientcodegen/src/Core/ApiClientCodeGen.Core.Tests/bin/Debug/net8.0/ApiClientCodeGen.Core.Tests.deps.json /home/REDACTED/work/apiclientcodegen/apiclientcodegen/src/Core/ApiClientCodeGen.Core.Tests/bin/Debug/net8.0/testhost.dll --port 39309 --endpoint 127.0.0.1:039309 --role client --parentprocessid 3624 --telemetryoptedin false
(dns block)/usr/lib/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/apiclientcodegen/apiclientcodegen/src/Core/ApiClientCodeGen.Core.Tests/bin/Debug/net8.0/ApiClientCodeGen.Core.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/apiclientcodegen/apiclientcodegen/src/Core/ApiClientCodeGen.Core.Tests/bin/Debug/net8.0/ApiClientCodeGen.Core.Tests.deps.json /home/REDACTED/work/apiclientcodegen/apiclientcodegen/src/Core/ApiClientCodeGen.Core.Tests/bin/Debug/net8.0/testhost.dll --port 43733 --endpoint 127.0.0.1:043733 --role client --parentprocessid 3776 --telemetryoptedin false
(dns block)s.symcb.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj
(dns block)s.symcd.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj
(dns block)ts-crl.ws.symantec.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj
(dns block)ts-ocsp.ws.symantec.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)www.microsoft.com
dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj
(dns block)dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.