Skip to content

Fix "Path too long" error in Kiota code generation #1164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 19, 2025

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

  • Added a new SafeReadAllLines method to FileHelper.cs that handles long file paths with multiple fallback strategies
  • Updated all file reading operations in CSharpFileMerger.cs to use the new robust file reading method
  • Added a unit test to validate the new file reading method works correctly

Implementation 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 normal File.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
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
  • crl4.digicert.com
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
    • Triggering command: dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj (dns block)
  • ocsp.digicert.com
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
    • Triggering command: dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj (dns block)
  • petstore.swagger.io
    • Triggering command: /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)
    • Triggering command: /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
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
    • Triggering command: dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj (dns block)
  • s.symcd.com
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
    • Triggering command: dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj (dns block)
  • ts-crl.ws.symantec.com
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
    • Triggering command: dotnet test src/VSIX/ApiClientCodegen.IntegrationTests/ApiClientCodegen.IntegrationTests.csproj (dns block)
  • ts-ocsp.ws.symantec.com
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
    • Triggering command: dotnet test src/Core/ApiClientCodeGen.Core.Tests/ApiClientCodeGen.Core.Tests.csproj (dns block)
  • www.microsoft.com
    • Triggering command: dotnet build src/Core/ApiClientCodeGen.Core/ApiClientCodeGen.Core.csproj (dns block)
    • Triggering command: 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.

Copilot AI and others added 2 commits May 19, 2025 21:33
Co-authored-by: christianhelle <710400+christianhelle@users.noreply.github.com>
Co-authored-by: christianhelle <710400+christianhelle@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Could not find a part of the path - AKA Path too long Fix "Path too long" error in Kiota code generation May 19, 2025
@Copilot Copilot AI requested a review from christianhelle May 19, 2025 21:38
Copilot finished work on behalf of christianhelle May 19, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could not find a part of the path - AKA Path too long
2 participants