-
Notifications
You must be signed in to change notification settings - Fork 22
fix: proxy body forwarding, part ID prefix, and SDK error handling for prompt_async #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
drewsephski
wants to merge
1
commit into
joelhooks:main
Choose a base branch
from
drewsephski:fix/proxy-body-part-id-sdk-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
@hey-api/openapi-ts client response error object shape body statusText status💡 Result:
In the
@hey-api/openapi-tsecosystem, the structure of error objects depends heavily on yourthrowOnErrorconfiguration and the specific client version used [1][2]. WhenthrowOnError: false(the default) is used, the client returns a result object with a standardized shape rather than throwing an exception [1][2]. This object contains: - error: The parsed error body (or undefined if no error occurred) [1][2]. - response: An object containing the response metadata, includingstatus,statusText, andheaders[1][2]. Note thatresponsemay be undefined if the error resulted from a network failure or request construction issue [1][3]. - request: The request object, which may also be undefined if the error occurred before the request was built [1][3]. WhenthrowOnError: trueis used, behavior varies by configuration: - Default Behavior: The client throws the raw parsed error body directly [4][2]. This often results in the loss of HTTP metadata (status codes, etc.) because the thrown value is a plain object rather than an Error instance [4][2]. - Wrapper Behavior (Opt-in): By configuring the client withthrowOnErrorStyle: 'wrapper'(available in newer versions), the client throws aFetchErrorinstance [2]. This class extendsErrorand explicitly exposes the following properties: -.error: The typed backend error body [2]. -.status: The HTTP status code [2]. -.statusText: The status text [2]. -.headers: The response headers [2]. -.request: The request object (may be undefined) [2]. -.response: The response object (may be undefined) [2]. To ensure robust error handling, it is recommended to check for the existence ofresponsebefore accessing its properties, as network-level errors will not have a response object [1][3]. If you require a consistent error shape throughout your application, using the 'wrapper' style is the preferred modern approach [2].Citations:
throwOnErrorthrows raw JSON object instead ofErrorinstance, losing HTTP status code hey-api/openapi-ts#3632Harden SDK error-to-
Errorconversion for non-stringerror.body@hey-api/openapi-ts’serrorfield contains the parsed backend error body when using the non-throwing result style, soerror.bodyis not guaranteed to be a string; if it’s an object,new Error(detail)will stringify to"[object Object]"and lose useful backend details.🛠️ Proposed normalization
const sdkResult = result as { - error?: { status?: number; statusText?: string; body?: string } + error?: { status?: number; statusText?: string; body?: unknown } data?: unknown } if (sdkResult.error) { - const detail = - sdkResult.error.body ?? sdkResult.error.statusText ?? "Unknown error" - throw new Error(detail) + const { status, statusText, body } = sdkResult.error + const bodyText = + typeof body === "string" ? body : body != null ? JSON.stringify(body) : undefined + const detail = bodyText ?? statusText ?? "Unknown error" + throw new Error(status ? `[${status}] ${detail}` : detail) }🤖 Prompt for AI Agents