Skip to content

fix: preserve nonstandard API error responses - #13

Merged
ark-hand[bot] merged 1 commit into
mainfrom
sync/handfix-335e98443a
Aug 21, 2026
Merged

fix: preserve nonstandard API error responses#13
ark-hand[bot] merged 1 commit into
mainfrom
sync/handfix-335e98443a

Conversation

@ark-hand

@ark-hand ark-hand Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Hand-written change from the internal SDK repository — not produced by make vendor.

  • source subject: fix: preserve nonstandard API error responses
  • attributed to ark-apis commit: 665a2441c2c8d9342e4770d776ea19de36ef6f83
  • reason: Manual error-handling fix (preserve nonstandard API error responses). No ark-apis regeneration involved; attributed to the same ark-apis snapshot as parent 9763808.

Summary

  • preserve standard wrapped API errors and direct error objects
  • retain arbitrary JSON and plain-text error bodies instead of returning RequestError with nil Err
  • return a clear local diagnostic when an error response has an empty body
  • prefer the server X-Request-Id header, then fall back to the client request ID
  • add regression coverage for wrapped, direct, nonstandard JSON, text, and empty responses

An empty body now produces unexpected error response: empty body; no placeholder is inserted into the body text.

Context

Found while running the public README Tokenization example with an intentionally invalid placeholder model. This is an existing SDK error-handling issue and is independent of the docs MR.

Validation

  • targeted TestHandleErrorResp covering all five response shapes
  • go test ./...
  • go build ./...
  • go vet ./...
  • golangci-lint run ./...

After this MR merges, docs/public-readme-byteplus will be rebased onto main and the CN/BP examples will be rerun.

See merge request: !82

Sync-Source-Commit: 335e98443a9aa0fcfd7eb20c2351801805b84cf0
Ark-APIs-Commit: 665a2441c2c8d9342e4770d776ea19de36ef6f83
Hand-Written-Reason: Manual error-handling fix (preserve nonstandard API error responses). No ark-apis regeneration involved; attributed to the same ark-apis snapshot as parent 9763808.
Release-Version: 0.3.0

Created by ark-hand.

## Summary

- preserve standard wrapped API errors and direct error objects
- retain arbitrary JSON and plain-text error bodies instead of returning RequestError with nil Err
- return a clear local diagnostic when an error response has an empty body
- prefer the server X-Request-Id header, then fall back to the client request ID
- add regression coverage for wrapped, direct, nonstandard JSON, text, and empty responses

An empty body now produces `unexpected error response: empty body`; no placeholder is inserted into the body text.

## Context

Found while running the public README Tokenization example with an intentionally invalid placeholder model. This is an existing SDK error-handling issue and is independent of the docs MR.

## Validation

- targeted TestHandleErrorResp covering all five response shapes
- go test ./...
- go build ./...
- go vet ./...
- golangci-lint run ./...

After this MR merges, docs/public-readme-byteplus will be rebased onto main and the CN/BP examples will be rerun.

See merge request: !82

Sync-Source-Commit: 335e98443a9aa0fcfd7eb20c2351801805b84cf0
Ark-APIs-Commit: 665a2441c2c8d9342e4770d776ea19de36ef6f83
Hand-Written-Reason: Manual error-handling fix (preserve nonstandard API error responses). No ark-apis regeneration involved; attributed to the same ark-apis snapshot as parent 9763808.
Release-Version: 0.3.0
@ark-hand
ark-hand Bot merged commit b7d5e3c into main Aug 21, 2026
1 check passed
@ark-hand
ark-hand Bot deleted the sync/handfix-335e98443a branch August 21, 2026 08:15
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.

0 participants