Skip to content

refactor(fail-fast): surface invalid JSON API responses - #13

Open
Gabrielgvl wants to merge 1 commit into
mainfrom
refactor/fail-fast-invalid-json-response
Open

refactor(fail-fast): surface invalid JSON API responses#13
Gabrielgvl wants to merge 1 commit into
mainfrom
refactor/fail-fast-invalid-json-response

Conversation

@Gabrielgvl

Copy link
Copy Markdown
Contributor

Problem

Malformed API responses were parsed as null and then rendered as empty/default payloads. That masked a real service contract failure and made plugin failures look like degraded success.

Root cause

parseJsonSafe(response) caught JSON parse errors and returned null for both successful and error responses.

Refactor

  • Added OrbioInvalidResponseError for malformed JSON response bodies.
  • Parse non-empty response bodies before retry decisions so invalid JSON fails fast instead of being retried or rendered as empty data.
  • Preserve existing 204 and empty-body success semantics.
  • Format invalid JSON errors with status and request id when available through runGuarded(...).
  • Updated tests to prove non-JSON success/error payloads no longer become empty/default payloads.

Risk

Low: only non-empty malformed JSON responses change behavior; valid JSON, 204, and empty-body success paths remain unchanged.

Validation

  • pnpm --filter @orbio/orbio-openclaw test — 45 passed
  • pnpm --filter @orbio/orbio-openclaw verify — passed (lint, typecheck, coverage 99.11% statements / 96.11% branches, env audit, build)

Malformed API payloads were previously parsed as empty data, which masked service contract failures and made debugging ambiguous. This change throws a typed invalid-response error before fallback rendering while preserving 204 and empty-body success semantics.
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codex PR review

Result: ❌ blocking
Exit code: 1
Timed out: no
Blocking findings: P0 0 | P1 0
Other findings: P2 0 | P3 0
Parser status: ok
Parser fallback used: no
Admin override: none
Override source: none
Override SHA: n/a

Top findings

  • none

Workflow logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant