Skip to content

[BUG] Unclear error message when API returns HTML instead of JSON #1068

@am6737

Description

@am6737

Quick Summary

When the API endpoint is misconfigured (e.g., wrong api_base URL), the API returns an HTML error page, but the error message is cryptic:
failed to unmarshal response: invalid character '<' looking for beginning of value
This doesn't help users identify that their api_base URL is wrong.

Environment & Tools

  • PicoClaw Version: latest (main branch)
  • Go Version: (e.g., go 1.22)
  • AI Model & Provider: (e.g., GPT-4o via OpenAI / DeepSeek via SiliconFlow)
  • Operating System: (e.g., Ubuntu 22.04 / macOS / Android Termux)
  • Channels: (e.g., Discord, Telegram, Feishu, ...)

📸 Steps to Reproduce

  1. Configure a model with an incorrect api_base URL (e.g., missing /v1 path)
  2. Run picoclaw agent -m "hello"
  3. Observe the unhelpful error message

❌ Actual Behavior

Generic JSON parse error that doesn't mention the root cause.

✅ Expected Behavior

The error message should clearly indicate:

  1. The API returned non-JSON content
  2. The Content-Type of the response
  3. Suggest checking the api_base URL configuration

💬 Additional Context

Proposed Fix

Add Content-Type header validation and HTML detection before attempting JSON unmarshal, with clear error messages guiding users to check their api_base URL.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions