mistral-debug-bundle

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mistral AI Debug Bundle

Mistral AI 调试包

Overview

概述

Collect all necessary diagnostic information for Mistral AI support tickets.
为Mistral AI支持工单收集所有必要的诊断信息。

Prerequisites

前提条件

  • Mistral AI SDK installed
  • Access to application logs
  • Permission to collect environment info
  • 已安装Mistral AI SDK
  • 可访问应用日志
  • 拥有收集环境信息的权限

Instructions

操作步骤

Step 1: Create Debug Bundle Script

步骤1:创建调试包脚本

bash
#!/bin/bash
bash
#!/bin/bash

mistral-debug-bundle.sh

mistral-debug-bundle.sh

BUNDLE_DIR="mistral-debug-$(date +%Y%m%d-%H%M%S)" mkdir -p "$BUNDLE_DIR"
echo "=== Mistral AI Debug Bundle ===" > "$BUNDLE_DIR/summary.txt" echo "Generated: $(date)" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
undefined
BUNDLE_DIR="mistral-debug-$(date +%Y%m%d-%H%M%S)" mkdir -p "$BUNDLE_DIR"
echo "=== Mistral AI Debug Bundle ===" > "$BUNDLE_DIR/summary.txt" echo "Generated: $(date)" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
undefined

Step 2: Collect Environment Info

步骤2:收集环境信息

bash
undefined
bash
undefined

Environment info

Environment info

echo "--- Environment ---" >> "$BUNDLE_DIR/summary.txt" echo "Node.js: $(node --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "Python: $(python3 --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "npm: $(npm --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "pip: $(pip --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "OS: $(uname -a)" >> "$BUNDLE_DIR/summary.txt" echo "MISTRAL_API_KEY: ${MISTRAL_API_KEY:+[SET]}" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
undefined
echo "--- Environment ---" >> "$BUNDLE_DIR/summary.txt" echo "Node.js: $(node --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "Python: $(python3 --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "npm: $(npm --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "pip: $(pip --version 2>/dev/null || echo 'not installed')" >> "$BUNDLE_DIR/summary.txt" echo "OS: $(uname -a)" >> "$BUNDLE_DIR/summary.txt" echo "MISTRAL_API_KEY: ${MISTRAL_API_KEY:+[SET]}" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
undefined

Step 3: Gather SDK and API Info

步骤3:收集SDK和API信息

bash
undefined
bash
undefined

SDK version (Node.js)

SDK version (Node.js)

echo "--- SDK Versions ---" >> "$BUNDLE_DIR/summary.txt" npm list @mistralai/mistralai 2>/dev/null >> "$BUNDLE_DIR/summary.txt" || echo "Node SDK: not installed" >> "$BUNDLE_DIR/summary.txt"
echo "--- SDK Versions ---" >> "$BUNDLE_DIR/summary.txt" npm list @mistralai/mistralai 2>/dev/null >> "$BUNDLE_DIR/summary.txt" || echo "Node SDK: not installed" >> "$BUNDLE_DIR/summary.txt"

SDK version (Python)

SDK version (Python)

pip show mistralai 2>/dev/null | grep -E "^(Name|Version)" >> "$BUNDLE_DIR/summary.txt" || echo "Python SDK: not installed" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
pip show mistralai 2>/dev/null | grep -E "^(Name|Version)" >> "$BUNDLE_DIR/summary.txt" || echo "Python SDK: not installed" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"

API connectivity test

API connectivity test

echo "--- API Connectivity ---" >> "$BUNDLE_DIR/summary.txt" echo -n "API Status: " >> "$BUNDLE_DIR/summary.txt" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}"
-H "Authorization: Bearer ${MISTRAL_API_KEY}"
https://api.mistral.ai/v1/models) echo "$HTTP_STATUS" >> "$BUNDLE_DIR/summary.txt"
echo "--- API Connectivity ---" >> "$BUNDLE_DIR/summary.txt" echo -n "API Status: " >> "$BUNDLE_DIR/summary.txt" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}"
-H "Authorization: Bearer ${MISTRAL_API_KEY}"
https://api.mistral.ai/v1/models) echo "$HTTP_STATUS" >> "$BUNDLE_DIR/summary.txt"

List available models (redact API key from output)

List available models (redact API key from output)

echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- Available Models ---" >> "$BUNDLE_DIR/summary.txt" curl -s -H "Authorization: Bearer ${MISTRAL_API_KEY}"
https://api.mistral.ai/v1/models 2>/dev/null |
jq -r '.data[].id' 2>/dev/null >> "$BUNDLE_DIR/summary.txt" ||
echo "Could not fetch models" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
undefined
echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- Available Models ---" >> "$BUNDLE_DIR/summary.txt" curl -s -H "Authorization: Bearer ${MISTRAL_API_KEY}"
https://api.mistral.ai/v1/models 2>/dev/null |
jq -r '.data[].id' 2>/dev/null >> "$BUNDLE_DIR/summary.txt" ||
echo "Could not fetch models" >> "$BUNDLE_DIR/summary.txt" echo "" >> "$BUNDLE_DIR/summary.txt"
undefined

Step 4: Collect Logs (Redacted)

步骤4:收集日志(已脱敏)

bash
undefined
bash
undefined

Recent logs (redacted)

Recent logs (redacted)

echo "--- Recent Logs (redacted) ---" >> "$BUNDLE_DIR/logs.txt" if [ -d "logs" ]; then grep -i "mistral" logs/*.log 2>/dev/null | tail -100 >> "$BUNDLE_DIR/logs.txt" fi
echo "--- Recent Logs (redacted) ---" >> "$BUNDLE_DIR/logs.txt" if [ -d "logs" ]; then grep -i "mistral" logs/*.log 2>/dev/null | tail -100 >> "$BUNDLE_DIR/logs.txt" fi

npm debug logs

npm debug logs

if [ -d "$HOME/.npm/_logs" ]; then grep -i "mistral" "$HOME/.npm/_logs"/*.log 2>/dev/null | tail -50 >> "$BUNDLE_DIR/logs.txt" fi
if [ -d "$HOME/.npm/_logs" ]; then grep -i "mistral" "$HOME/.npm/_logs"/*.log 2>/dev/null | tail -50 >> "$BUNDLE_DIR/logs.txt" fi

Configuration (redacted - secrets masked)

Configuration (redacted - secrets masked)

echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- Config (redacted) ---" >> "$BUNDLE_DIR/summary.txt" if [ -f ".env" ]; then cat .env 2>/dev/null | sed 's/=.*/=REDACTED/' >> "$BUNDLE_DIR/config-redacted.txt" fi
echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- Config (redacted) ---" >> "$BUNDLE_DIR/summary.txt" if [ -f ".env" ]; then cat .env 2>/dev/null | sed 's/=.*/=REDACTED/' >> "$BUNDLE_DIR/config-redacted.txt" fi

package.json dependencies

package.json dependencies

if [ -f "package.json" ]; then echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- Dependencies ---" >> "$BUNDLE_DIR/summary.txt" jq '.dependencies, .devDependencies' package.json 2>/dev/null >> "$BUNDLE_DIR/summary.txt" fi
undefined
if [ -f "package.json" ]; then echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- Dependencies ---" >> "$BUNDLE_DIR/summary.txt" jq '.dependencies, .devDependencies' package.json 2>/dev/null >> "$BUNDLE_DIR/summary.txt" fi
undefined

Step 5: Capture Error Details

步骤5:捕获错误详情

bash
undefined
bash
undefined

Error reproduction script

Error reproduction script

cat > "$BUNDLE_DIR/reproduce.sh" << 'SCRIPT' #!/bin/bash
cat > "$BUNDLE_DIR/reproduce.sh" << 'SCRIPT' #!/bin/bash

Minimal reproduction script

Minimal reproduction script

curl -X POST https://api.mistral.ai/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer ${MISTRAL_API_KEY}"
-d '{ "model": "mistral-small-latest", "messages": [{"role": "user", "content": "Hello"}] }' 2>&1
echo "" echo "Exit code: $?" SCRIPT chmod +x "$BUNDLE_DIR/reproduce.sh"
undefined
curl -X POST https://api.mistral.ai/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer ${MISTRAL_API_KEY}"
-d '{ "model": "mistral-small-latest", "messages": [{"role": "user", "content": "Hello"}] }' 2>&1
echo "" echo "Exit code: $?" SCRIPT chmod +x "$BUNDLE_DIR/reproduce.sh"
undefined

Step 6: Package Bundle

步骤6:打包调试包

bash
undefined
bash
undefined

Create timestamp file

Create timestamp file

echo "Bundle created: $(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$BUNDLE_DIR/timestamp.txt"
echo "Bundle created: $(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$BUNDLE_DIR/timestamp.txt"

Package everything

Package everything

tar -czf "$BUNDLE_DIR.tar.gz" "$BUNDLE_DIR" rm -rf "$BUNDLE_DIR"
echo "Bundle created: $BUNDLE_DIR.tar.gz" echo "" echo "IMPORTANT: Review the bundle for sensitive data before sharing!" echo "Run: tar -tzf $BUNDLE_DIR.tar.gz"
undefined
tar -czf "$BUNDLE_DIR.tar.gz" "$BUNDLE_DIR" rm -rf "$BUNDLE_DIR"
echo "Bundle created: $BUNDLE_DIR.tar.gz" echo "" echo "IMPORTANT: Review the bundle for sensitive data before sharing!" echo "Run: tar -tzf $BUNDLE_DIR.tar.gz"
undefined

Complete Script

完整脚本

bash
#!/bin/bash
bash
#!/bin/bash

mistral-debug-bundle.sh - Complete version

mistral-debug-bundle.sh - Complete version

set -e
BUNDLE_DIR="mistral-debug-$(date +%Y%m%d-%H%M%S)" mkdir -p "$BUNDLE_DIR"
echo "Creating Mistral AI debug bundle..."
set -e
BUNDLE_DIR="mistral-debug-$(date +%Y%m%d-%H%M%S)" mkdir -p "$BUNDLE_DIR"
echo "Creating Mistral AI debug bundle..."

Summary file

Summary file

cat > "$BUNDLE_DIR/summary.txt" << EOF === Mistral AI Debug Bundle === Generated: $(date) Hostname: $(hostname)
--- Environment --- Node.js: $(node --version 2>/dev/null || echo 'not installed') Python: $(python3 --version 2>/dev/null || echo 'not installed') OS: $(uname -a) MISTRAL_API_KEY: ${MISTRAL_API_KEY:+[SET]}
--- SDK Versions --- EOF
npm list @mistralai/mistralai 2>/dev/null >> "$BUNDLE_DIR/summary.txt" || echo "Node SDK: not installed" >> "$BUNDLE_DIR/summary.txt" pip show mistralai 2>/dev/null | grep -E "^(Name|Version)" >> "$BUNDLE_DIR/summary.txt" || echo "Python SDK: not installed" >> "$BUNDLE_DIR/summary.txt"
echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- API Test ---" >> "$BUNDLE_DIR/summary.txt" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${MISTRAL_API_KEY}" https://api.mistral.ai/v1/models 2>/dev/null) echo "HTTP Status: $HTTP_STATUS" >> "$BUNDLE_DIR/summary.txt"
cat > "$BUNDLE_DIR/summary.txt" << EOF === Mistral AI Debug Bundle === Generated: $(date) Hostname: $(hostname)
--- Environment --- Node.js: $(node --version 2>/dev/null || echo 'not installed') Python: $(python3 --version 2>/dev/null || echo 'not installed') OS: $(uname -a) MISTRAL_API_KEY: ${MISTRAL_API_KEY:+[SET]}
--- SDK Versions --- EOF
npm list @mistralai/mistralai 2>/dev/null >> "$BUNDLE_DIR/summary.txt" || echo "Node SDK: not installed" >> "$BUNDLE_DIR/summary.txt" pip show mistralai 2>/dev/null | grep -E "^(Name|Version)" >> "$BUNDLE_DIR/summary.txt" || echo "Python SDK: not installed" >> "$BUNDLE_DIR/summary.txt"
echo "" >> "$BUNDLE_DIR/summary.txt" echo "--- API Test ---" >> "$BUNDLE_DIR/summary.txt" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${MISTRAL_API_KEY}" https://api.mistral.ai/v1/models 2>/dev/null) echo "HTTP Status: $HTTP_STATUS" >> "$BUNDLE_DIR/summary.txt"

Redacted config

Redacted config

if [ -f ".env" ]; then cat .env | sed 's/=.*/=REDACTED/' > "$BUNDLE_DIR/config-redacted.txt" fi
if [ -f ".env" ]; then cat .env | sed 's/=.*/=REDACTED/' > "$BUNDLE_DIR/config-redacted.txt" fi

Package

Package

tar -czf "$BUNDLE_DIR.tar.gz" "$BUNDLE_DIR" rm -rf "$BUNDLE_DIR"
echo "Bundle created: $BUNDLE_DIR.tar.gz"
undefined
tar -czf "$BUNDLE_DIR.tar.gz" "$BUNDLE_DIR" rm -rf "$BUNDLE_DIR"
echo "Bundle created: $BUNDLE_DIR.tar.gz"
undefined

Output

输出

  • mistral-debug-YYYYMMDD-HHMMSS.tar.gz
    archive containing:
    • summary.txt
      - Environment and SDK info
    • logs.txt
      - Recent redacted logs
    • config-redacted.txt
      - Configuration (secrets removed)
    • reproduce.sh
      - Minimal reproduction script
  • mistral-debug-YYYYMMDD-HHMMSS.tar.gz
    压缩包包含:
    • summary.txt
      - 环境和SDK信息
    • logs.txt
      - 近期脱敏日志
    • config-redacted.txt
      - 配置信息(已移除敏感信息)
    • reproduce.sh
      - 最小化复现脚本

Error Handling

错误处理

ItemPurposeIncluded
Environment versionsCompatibility checkYes
SDK versionVersion-specific bugsYes
Error logs (redacted)Root cause analysisYes
Config (redacted)Configuration issuesYes
API connectivity testNetwork issuesYes
项目用途是否包含
环境版本兼容性检查
SDK版本特定版本 bug 排查
错误日志(已脱敏)根因分析
配置信息(已脱敏)配置问题排查
API连通性测试网络问题排查

Sensitive Data Handling

敏感数据处理

ALWAYS REDACT:
  • API keys and tokens
  • Passwords and secrets
  • PII (emails, names, IDs)
  • Internal URLs and IPs
Safe to Include:
  • Error messages
  • Stack traces (redacted)
  • SDK/runtime versions
  • HTTP status codes
务必脱敏:
  • API密钥和令牌
  • 密码和机密信息
  • 个人可识别信息(邮箱、姓名、ID)
  • 内部URL和IP地址
可安全包含:
  • 错误信息
  • 堆栈跟踪(已脱敏)
  • SDK/运行时版本
  • HTTP状态码

TypeScript Debug Helper

TypeScript 调试助手

typescript
interface DebugInfo {
  timestamp: string;
  sdkVersion: string;
  nodeVersion: string;
  apiKeySet: boolean;
  lastError?: {
    message: string;
    status?: number;
    requestId?: string;
  };
}

function collectDebugInfo(error?: Error): DebugInfo {
  return {
    timestamp: new Date().toISOString(),
    sdkVersion: require('@mistralai/mistralai/package.json').version,
    nodeVersion: process.version,
    apiKeySet: !!process.env.MISTRAL_API_KEY,
    lastError: error ? {
      message: error.message,
      status: (error as any).status,
      requestId: (error as any).requestId,
    } : undefined,
  };
}

// Usage
try {
  await client.chat.complete({ /* ... */ });
} catch (error) {
  const debug = collectDebugInfo(error as Error);
  console.error('Debug info:', JSON.stringify(debug, null, 2));
}
typescript
interface DebugInfo {
  timestamp: string;
  sdkVersion: string;
  nodeVersion: string;
  apiKeySet: boolean;
  lastError?: {
    message: string;
    status?: number;
    requestId?: string;
  };
}

function collectDebugInfo(error?: Error): DebugInfo {
  return {
    timestamp: new Date().toISOString(),
    sdkVersion: require('@mistralai/mistralai/package.json').version,
    nodeVersion: process.version,
    apiKeySet: !!process.env.MISTRAL_API_KEY,
    lastError: error ? {
      message: error.message,
      status: (error as any).status,
      requestId: (error as any).requestId,
    } : undefined,
  };
}

// Usage
try {
  await client.chat.complete({ /* ... */ });
} catch (error) {
  const debug = collectDebugInfo(error as Error);
  console.error('Debug info:', JSON.stringify(debug, null, 2));
}

Resources

相关资源

Next Steps

后续步骤

For rate limit issues, see
mistral-rate-limits
.
若遇到速率限制问题,请查看
mistral-rate-limits