{"meta":{"title":"Guide de débogage","intro":"Ce guide traite des problèmes courants et des techniques de débogage pour le sdk Copilot sur tous les langages pris en charge.","product":"GitHub Copilot","breadcrumbs":[{"href":"/fr/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/fr/enterprise-cloud@latest/copilot/how-tos","title":"Procédures"},{"href":"/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk","title":"Kit de développement logiciel (SDK) Copilot"},{"href":"/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/troubleshooting","title":"Résolution des problèmes"},{"href":"/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/troubleshooting/debugging","title":"Débogage"}],"documentType":"article"},"body":"# Guide de débogage\n\nCe guide traite des problèmes courants et des techniques de débogage pour le sdk Copilot sur tous les langages pris en charge.\n\n<!-- markdownlint-disable GHD046 GHD005 -->\n\n<!-- Suppressed: GHD046 (outdated release terminology), GHD005 (hardcoded data variable) -->\n\n## Table des matières\n\n* [Activer la journalisation du débogage](#enable-debug-logging)\n* [Problèmes courants](#common-issues)\n* [Débogage du serveur MCP](#mcp-server-debugging)\n* [Problèmes de connexion](#connection-issues)\n* [Problèmes d’exécution des outils](#tool-execution-issues)\n* [Problèmes spécifiques à la plateforme](#platform-specific-issues)\n\n## Activer l’enregistrement du débogage\n\nLa première étape du débogage consiste à activer la journalisation détaillée pour voir ce qui se passe sous le capot.\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nimport { CopilotClient } from \"@github/copilot-sdk\";\n\nconst client = new CopilotClient({\n  logLevel: \"debug\",  // Options: \"none\", \"error\", \"warning\", \"info\", \"debug\", \"all\"\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nfrom copilot import CopilotClient\n\nclient = CopilotClient(log_level=\"debug\")\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nimport copilot \"github.com/github/copilot-sdk/go\"\n\nclient := copilot.NewClient(&copilot.ClientOptions{\n    LogLevel: \"debug\",\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n<!-- docs-validate: skip -->\n\n```csharp\nusing GitHub.Copilot;\nusing Microsoft.Extensions.Logging;\n\n// Using ILogger\nvar loggerFactory = LoggerFactory.Create(builder =>\n{\n    builder.SetMinimumLevel(LogLevel.Debug);\n    builder.AddConsole();\n});\n\nvar client = new CopilotClient(new CopilotClientOptions\n{\n    LogLevel = \"debug\",\n    Logger = loggerFactory.CreateLogger<CopilotClient>()\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nimport com.github.copilot.CopilotClient;\nimport com.github.copilot.rpc.*;\n\nvar client = new CopilotClient(new CopilotClientOptions()\n    .setLogLevel(\"debug\")\n);\n```\n\n</div>\n\n</div>\n\n### Répertoire du journal\n\nL’interface CLI écrit des journaux dans un répertoire. Vous pouvez spécifier un emplacement personnalisé :\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nconst client = new CopilotClient({\n  cliArgs: [\"--log-dir\", \"/path/to/logs\"],\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\n# The Python SDK does not currently support passing extra CLI arguments.\n# Logs are written to the default location or can be configured via\n# the CLI when running in server mode.\n```\n\n> \\[!NOTE]\n> La configuration de journalisation du SDK Python est limitée. Pour la journalisation avancée, exécutez l’interface CLI manuellement avec `--log-dir` et connectez-vous via `RuntimeConnection.for_uri(...)`.\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nclient := copilot.NewClient(&copilot.ClientOptions{\n    Connection: copilot.StdioConnection{\n        Args: []string{\"--log-dir\", \"/path/to/logs\"},\n    },\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nvar client = new CopilotClient(new CopilotClientOptions\n{\n    Connection = RuntimeConnection.ForStdio(args: new[] { \"--log-dir\", \"/path/to/logs\" })\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n<!-- docs-validate: skip -->\n\n```java\n// The Java SDK does not currently support passing extra CLI arguments.\n// For custom log directories, run the CLI manually with --log-dir\n// and connect via cliUrl.\n```\n\n</div>\n\n</div>\n\n## Problèmes courants\n\n### « CLI introuvable » / « Copilot : commande introuvable »\n\n**Cause :** L’interface CLI Copilot n’est pas installée ou non dans PATH.\n\n**Solution:**\n\n1. Installer l’interface CLI : [Guide d’installation](/fr/enterprise-cloud@latest/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli)\n\n2. Vérifiez l’installation :\n\n   ```bash\n   copilot --version\n   ```\n\n3. Ou spécifiez le chemin d’accès complet :\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"javascript\" data-label=\"JavaScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">JavaScript</div>\n\n```typescript\nconst client = new CopilotClient({\n  cliPath: \"/usr/local/bin/copilot\",\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nclient = CopilotClient({\"cli_path\": \"/usr/local/bin/copilot\"})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nclient := copilot.NewClient(&copilot.ClientOptions{\n    Connection: copilot.StdioConnection{Path: \"/usr/local/bin/copilot\"},\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nvar client = new CopilotClient(new CopilotClientOptions\n{\n    CliPath = \"/usr/local/bin/copilot\"\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nvar client = new CopilotClient(new CopilotClientOptions()\n    .setCliPath(\"/usr/local/bin/copilot\")\n);\n```\n\n</div>\n\n</div>\n\n### « Non authentifié »\n\n**Cause :** L’interface CLI n’est pas authentifiée avec GitHub.\n\n**Solution:**\n\n1. Authentifiez l’interface CLI :\n\n   ```bash\n   copilot auth login\n   ```\n\n2. Ou fournissez un jeton de manière programmatique :\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"javascript\" data-label=\"JavaScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">JavaScript</div>\n\n```typescript\nconst client = new CopilotClient({\n  gitHubToken: process.env.GITHUB_TOKEN,\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nimport os\nclient = CopilotClient({\"github_token\": os.environ.get(\"GITHUB_TOKEN\")})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nclient := copilot.NewClient(&copilot.ClientOptions{\n    GitHubToken: os.Getenv(\"GITHUB_TOKEN\"),\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nvar client = new CopilotClient(new CopilotClientOptions\n{\n    GitHubToken = Environment.GetEnvironmentVariable(\"GITHUB_TOKEN\")\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nvar client = new CopilotClient(new CopilotClientOptions()\n    .setGitHubToken(System.getenv(\"GITHUB_TOKEN\"))\n);\n```\n\n</div>\n\n</div>\n\n### « Session introuvable »\n\n**Cause :** Tentative d’utilisation d’une session qui a été détruite ou qui n’existe pas.\n\n**Solution:**\n\n1. Vérifiez que vous n’appelez pas les méthodes après `disconnect()`:\n\n   ```typescript\n   await session.disconnect();\n   // Don't use session after this!\n   ```\n\n2. Pour reprendre des sessions, vérifiez que l’ID de session existe :\n\n   ```typescript\n   const sessions = await client.listSessions();\n   console.log(\"Available sessions:\", sessions);\n   ```\n\n### « Connexion refusée » / « ECONNREFUSED »\n\n**Cause :** Le processus du serveur CLI a échoué ou n’a pas pu démarrer.\n\n**Solution:**\n\n1. Vérifiez si l’interface CLI s’exécute correctement autonome :\n\n   ```bash\n   copilot --server --stdio\n   ```\n\n2. Vérifiez les conflits de ports si vous utilisez le mode TCP :\n\n   ```typescript\n   const client = new CopilotClient({\n     useStdio: false,\n     port: 0,  // Use random available port\n   });\n   ```\n\n## Débogage du serveur MCP\n\nLes serveurs MCP (Model Context Protocol) peuvent être difficiles à déboguer. Pour obtenir des conseils complets sur le débogage MCP, consultez **[l’AUTOTITLE](/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/troubleshooting/mcp-debugging)** dédié.\n\n### Liste de contrôle MCP rapide\n\n* [ ] Le fichier exécutable du serveur MCP existe et s’exécute indépendamment\n* [ ] Chemin de commande correct (utiliser des chemins absolus)\n* [ ] Les outils sont activés : `tools: [\"*\"]`\n* [ ] Le serveur répond correctement à la `initialize` demande\n* [ ] Répertoire de travail (`cwd`) est défini si nécessaire\n\n### Tester votre serveur MCP\n\nAvant d’intégrer le Kit de développement logiciel (SDK), vérifiez que votre serveur MCP fonctionne :\n\n```bash\necho '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"}}}' | /path/to/your/mcp-server\n```\n\nConsultez [Guide de débogage du serveur MCP](/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/troubleshooting/mcp-debugging) pour obtenir une résolution des problèmes détaillée.\n\n## Problèmes de connexion\n\n### stdio vs mode TCP\n\nLe Kit de développement logiciel (SDK) prend en charge deux modes de transport :\n\n| Mode                   | Description                                                                     | Cas d’usage                               |\n| ---------------------- | ------------------------------------------------------------------------------- | ----------------------------------------- |\n| **Stdio** (par défaut) | L’interface CLI s’exécute en tant que sous-processus, communique via des canaux | Développement local, processus unique     |\n| **TCP**                | L’interface CLI s’exécute séparément, communique via le socket TCP              | Plusieurs clients, interface CLI distante |\n\n**Mode Stdio (par défaut) :**\n\n```typescript\nconst client = new CopilotClient({\n  useStdio: true,  // This is the default\n});\n```\n\n**Mode TCP :**\n\n```typescript\nconst client = new CopilotClient({\n  useStdio: false,\n  port: 8080,  // Or 0 for random port\n});\n```\n\n**Connectez-vous au serveur existant :**\n\n```typescript\nconst client = new CopilotClient({\n  cliUrl: \"localhost:8080\",  // Connect to running server\n});\n```\n\n### Diagnostic des échecs de connexion\n\n1. **Vérifiez l’état du client :**\n\n   ```typescript\n   console.log(\"Connection state:\", client.getState());\n   // Should be \"connected\" after start()\n   ```\n\n2. **Écoutez les modifications d’état :**\n\n   ```typescript\n   client.on(\"stateChange\", (state) => {\n     console.log(\"State changed to:\", state);\n   });\n   ```\n\n3. **Vérifiez que le processus CLI est en cours d’exécution :**\n\n   ```bash\n   # Check for copilot processes\n   ps aux | grep copilot\n   ```\n\n## Problèmes d’exécution des outils\n\n### Outil personnalisé n’est pas appelé\n\n1. **Vérifier l’inscription de l’outil :**\n\n   ```typescript\n   const session = await client.createSession({\n     tools: [myTool],\n   });\n\n   // Check registered tools\n   console.log(\"Registered tools:\", session.getTools?.());\n   ```\n\n2. **Le schéma de l’outil de vérification est un schéma JSON valide :**\n\n   ```typescript\n   const myTool = {\n     name: \"get_weather\",\n     description: \"Get weather for a location\",\n     parameters: {\n       type: \"object\",\n       properties: {\n         location: { type: \"string\", description: \"City name\" },\n       },\n       required: [\"location\"],\n     },\n     handler: async (args) => {\n       return { temperature: 72 };\n     },\n   };\n   ```\n\n3. **Vérifiez que le gestionnaire retourne un résultat valide :**\n\n   ```typescript\n   handler: async (args) => {\n     // Must return something JSON-serializable\n     return { success: true, data: \"result\" };\n     \n     // Don't return undefined or non-serializable objects\n   }\n   ```\n\n### Erreurs d’outil non affichées\n\nS’abonner aux événements d’erreur :\n\n```typescript\nsession.on(\"tool.execution_error\", (event) => {\n  console.error(\"Tool error:\", event.data);\n});\n\nsession.on(\"error\", (event) => {\n  console.error(\"Session error:\", event.data);\n});\n```\n\n## Problèmes spécifiques à la plateforme\n\n### Windows\n\n1. **Séparateurs de chemin :** Utilisez des chaînes brutes ou des barres obliques :\n\n   ```csharp\n   CliPath = @\"C:\\Program Files\\GitHub\\copilot.exe\"\n   // or\n   CliPath = \"C:/Program Files/GitHub/copilot.exe\"\n   ```\n\n2. **Résolution PATHEXT :** Le Kit de développement logiciel (SDK) gère cette opération automatiquement, mais si les problèmes persistent :\n\n   ```csharp\n   // Explicitly specify .exe\n   Command = \"myserver.exe\"  // Not just \"myserver\"\n   ```\n\n3. **Encodage de la console :** Vérifiez UTF-8 pour une gestion JSON appropriée :\n\n   ```csharp\n   Console.OutputEncoding = System.Text.Encoding.UTF8;\n   ```\n\n### macOS\n\n1. **Problèmes liés à Gatekeeper :** Si l’interface CLI est bloquée :\n\n   ```bash\n   xattr -d com.apple.quarantine /path/to/copilot\n   ```\n\n2. **Problèmes PATH dans les applications GUI :** Les applications GUI peuvent ne pas hériter du chemin d’accès de l’interpréteur de commandes :\n\n   ```typescript\n   const client = new CopilotClient({\n     cliPath: \"/opt/homebrew/bin/copilot\",  // Full path\n   });\n   ```\n\n### Linux\n\n1. **Problèmes d’autorisation :**\n\n   ```bash\n   chmod +x /path/to/copilot\n   ```\n\n2. **Bibliothèques manquantes :** Recherchez les bibliothèques partagées requises :\n\n   ```bash\n   ldd /path/to/copilot\n   ```\n\n## Obtention d’aide\n\nSi vous êtes toujours bloqué :\n\n1. **Collectez les informations de débogage :**\n   * Version du SDK\n   * Version de l’interface CLI (`copilot --version`)\n   * Système d'exploitation\n   * Journaux de débogage\n   * Code de reproduction minimal\n\n2. problèmes existants **Search :**[GitHub Problèmes](https://github.com/github/copilot-sdk/issues)\n\n3. **Ouvrir une nouvelle issue** avec les informations collectées\n\n## Voir aussi\n\n* [Créez votre première application avec Copilot](/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/getting-started)\n* [Utilisation de serveurs MCP avec le SDK GitHub Copilot](/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/features/mcp) - Configuration et installation de MCP\n* [Guide de débogage du serveur MCP](/fr/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/troubleshooting/mcp-debugging) - Résolution détaillée des problèmes MCP\n* [Référence sur l’API](https://github.com/github/copilot-sdk)"}