iflytek/astron-agent · warning · HTTPException

Invalid JSON format for 'params

Error message

Invalid JSON format for 'params': {e}

What it means

exec_fun validates that the 'params' field of the RPA execution request is valid JSON. If json.loads on the params fails, it converts the JSONDecodeError into an HTTP 400 with detail 'Invalid JSON format for 'params': <reason>'. This is a client-input error surfaced through FastAPI's HTTPException.

Solutions

  1. Fix the client to send syntactically valid JSON in 'params' — validate with json.loads before sending
  2. Build params programmatically with json.dumps rather than hand-formatted strings
  3. Check the HTTP response 400 detail; it names the exact character/line where parsing failed

Example fix

// before (client)
params = "{'key': 'value'}"  // single quotes -> invalid JSON
// after
import json
params = json.dumps({"key": "value"})  // '{"key": "value"}'
Defensive patterns

Strategy: validation

Validate before calling

import json
def valid_params(params: str) -> bool:
    try:
        json.loads(params)
        return True
    except json.JSONDecodeError:
        return False

Try / catch

try:
    resp = requests.post(url, json={"params": params_json_str, ...})
except requests.HTTPError as e:
    if e.response.status_code == 400:
        # fix params JSON on the client side
        ...

Prevention

When it happens

Trigger: POSTing to the RPA execution endpoint with a 'params' value that is not valid JSON — unquoted strings, single quotes, trailing commas, embedded newlines in strings, or an already-encoded JSON string double-encoded incorrectly.

Common situations: Frontend sending stringified params with quoting mistakes; users pasting params with single quotes; params built via naive string concatenation instead of json.dumps; testing tools (curl/Postman) sending raw text in the params field.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/cb5a42b4151d2bc1. Report an issue: GitHub.

Appendix: source

Thrown at core/plugin/rpa/api/v1/execution.py:56

        acctss_token = (
            Authorization[7:] if Authorization.startswith("Bearer ") else Authorization
        )
        return EventSourceResponse(
            task_monitoring(
                sid=request.sid,
                access_token=acctss_token,
                project_id=request.project_id,
                version=request.version,
                phone_number=request.phone_number,
                exec_position=request.exec_position,
                params=request.params,
            ),
            headers=headers,
            ping=ping_interval,
        )
    except json.JSONDecodeError as e:
        raise HTTPException(
            status_code=400, detail=f"Invalid JSON format for 'params':" f" {e}"
        ) from e
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e)) from e

View on GitHub (pinned to 5e758547a8)