FujiwaraChoki/MoneyPrinterV2 · error · PostBridgeClientError
Post Bridge returned an invalid social accounts payload.
Error message
Post Bridge returned an invalid social accounts payload.
What it means
Raised by PostBridgeClient.list_social_accounts when the response's 'data' field (or the response body itself, as fallback) is not a JSON list. The paginator expects an array of account objects per page, so any other shape aborts the loop.
Source
Thrown at src/classes/PostBridge.py:77
if platforms:
for platform in platforms:
params.append(("platform", platform))
url = f"{self.API_BASE}/social-accounts"
accounts = []
is_first_request = True
while url:
response_json = self._request_json(
"GET",
url,
params=params if is_first_request else None,
)
is_first_request = False
page_accounts = response_json.get("data", response_json)
if not isinstance(page_accounts, list):
raise PostBridgeClientError(
"Post Bridge returned an invalid social accounts payload."
)
accounts.extend(page_accounts)
meta = response_json.get("meta", {})
url = meta.get("next") if isinstance(meta, dict) else None
return accounts
def upload_media(self, file_path: str) -> str:
"""
Upload a local media file to Post Bridge and return its media ID.
Args:
file_path (str): Absolute path to a local media file.
Returns:View on GitHub (pinned to 5192af8eca)
Solutions
- Log the raw response_json to see the actual shape returned
- Update the extraction to match the current API envelope (e.g. response_json.get('accounts', []))
- Check for an error/message key in the payload before treating it as data
- Verify the endpoint and API version in the Post Bridge account settings
Example fix
// before
page_accounts = response_json.get("data", response_json)
if not isinstance(page_accounts, list):
raise PostBridgeClientError("Post Bridge returned an invalid social accounts payload.")
// after
page_accounts = (
response_json.get("data")
if isinstance(response_json.get("data"), list)
else response_json.get("accounts", [])
)
if not isinstance(page_accounts, list):
raise PostBridgeClientError(
f"Unexpected social accounts payload: {response_json!r}"
) Defensive patterns
Strategy: type-guard
Validate before calling
response_json = client._request_json("GET", url, params=params)
if not isinstance(response_json.get("data", response_json), list):
logging.warning("Unexpected Post Bridge payload shape: %r", response_json)
# fall back to a known-good envelope or abort gracefully Type guard
def is_social_accounts_payload(payload: object) -> bool:
if not isinstance(payload, dict):
return False
data = payload.get("data", payload)
return isinstance(data, list) and all(isinstance(a, dict) for a in data) Try / catch
try:
accounts = client.list_social_accounts()
except PostBridgeClientError as exc:
if "invalid social accounts payload" in str(exc):
logging.error("Post Bridge API envelope changed; got: %s", exc)
return []
raise Prevention
- Log raw response bodies (truncated) whenever envelope-shape errors occur
- Pin the Post Bridge API version if the client supports versioned endpoints
- Add integration tests that assert the payload shape on every release
When it happens
Trigger: The API returns a dict per page (e.g. {'accounts': [...]}) so response_json.get('data', response_json) yields a dict; an error payload like {'error': ...} with 200 status; an empty-string or null 'data' field.
Common situations: Post Bridge API version change altering the payload envelope, a proxy/gateway returning an HTML or object error page, or rate-limit responses that don't set a non-200 status.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Post Bridge did not return a media_id and upload_url.
- Post Bridge returned a non-JSON response.
- Media file does not exist: {file_path}
- Request to Post Bridge failed: {last_exception}
- Unsupported provider '{provider}'. Expected 'twitter' or 'yo
AI-assisted analysis of FujiwaraChoki/MoneyPrinterV2@5192af8eca (2026-08-28).
Data as JSON: /api/errors/a347525586426657.
Report an issue: GitHub.