Skip to content

feat: show request execution error status code, close #1049#1082

Merged
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp
Mar 16, 2026
Merged

feat: show request execution error status code, close #1049#1082
looplj merged 1 commit intorelease/v0.9.xfrom
dev-tmp

Conversation

@looplj
Copy link
Copy Markdown
Owner

@looplj looplj commented Mar 16, 2026

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the visibility and handling of request execution errors by introducing the capability to store and display HTTP status codes. The changes span the entire stack, from updating the database schema and GraphQL API to modifying frontend components and backend business logic. This ensures that users receive clearer feedback on why a request failed, while also improving the robustness of internal error management and channel health monitoring.

Highlights

  • Enhanced Error Visibility: The frontend now displays the HTTP status code for failed request executions, providing more detailed error information to users.
  • Backend Data Model Update: A new response_status_code field has been added to the RequestExecution entity across the database schema, Go ent framework, and GraphQL API to store and retrieve HTTP status codes.
  • Improved Error Handling Logic: Backend services and tests have been updated to consistently use the new response_status_code field for error tracking and channel auto-disabling logic, replacing the previous errorStatusCode.
Changelog
  • frontend/src/features/requests/components/request-detail-page.tsx
    • Modified the error message display to include the HTTP status code for failed request executions.
  • frontend/src/features/requests/data/requests.ts
    • Updated the GraphQL query to fetch the new responseStatusCode for request executions.
  • frontend/src/features/requests/data/schema.ts
    • Added responseStatusCode as an optional number field to the requestExecutionSchema.
  • internal/ent/entql.go
    • Registered the new response_status_code field in the schema graph.
    • Added a WhereResponseStatusCode method for filtering request executions by status code.
  • internal/ent/gql_collection.go
    • Included responseStatusCode in the fields collected for GraphQL queries.
  • internal/ent/gql_node_descriptor.go
    • Adjusted the field count and mapping to accommodate the new response_status_code field in the GraphQL node descriptor.
  • internal/ent/gql_where_input.go
    • Added various predicates for responseStatusCode to the RequestExecutionWhereInput type for GraphQL filtering.
  • internal/ent/migrate/schema.go
    • Added a new response_status_code column to the request_executions table.
    • Updated foreign key column indices to reflect the addition of the new column.
  • internal/ent/mutation.go
    • Incorporated response_status_code into the RequestExecutionMutation struct.
    • Implemented methods for setting, getting, adding, clearing, and resetting the response_status_code field within mutations.
  • internal/ent/requestexecution.go
    • Added ResponseStatusCode field to the RequestExecution struct.
    • Updated scanValues to handle the new response_status_code field.
    • Modified assignValues to correctly assign the response_status_code from database scans.
    • Updated the String method to include response_status_code in the string representation.
  • internal/ent/requestexecution/requestexecution.go
    • Defined FieldResponseStatusCode constant.
    • Added FieldResponseStatusCode to the list of columns.
    • Introduced ByResponseStatusCode for ordering query results.
  • internal/ent/requestexecution/where.go
    • Added ResponseStatusCode and various predicates (EQ, NEQ, In, NotIn, GT, GTE, LT, LTE, IsNil, NotNil) for the response_status_code field.
  • internal/ent/requestexecution_create.go
    • Added SetResponseStatusCode and SetNillableResponseStatusCode methods for creating request executions.
    • Updated createSpec to handle the response_status_code field during creation.
  • internal/ent/requestexecution_update.go
    • Added methods to set, add, and clear the response_status_code field during updates.
    • Updated sqlSave to include logic for updating the response_status_code field.
  • internal/ent/runtime/runtime.go
    • Adjusted the index for requestexecutionDescStream due to the insertion of a new field.
  • internal/ent/schema/request_execution.go
    • Added a new response_status_code field to the RequestExecution schema, marked as optional and nillable, with a comment describing its purpose.
  • internal/server/biz/channel_auto_disable.go
    • Updated markChannelUnavailable to use responseStatusCode instead of errorStatusCode.
    • Modified checkAndHandleChannelError and checkAndHandleAPIKeyError to use ResponseStatusCode for error tracking and auto-disabling logic.
  • internal/server/biz/channel_auto_disable_test.go
    • Updated test cases to use ResponseStatusCode instead of ErrorStatusCode in PerformanceRecord.
  • internal/server/biz/channel_metrics.go
    • Renamed ErrorStatusCode to ResponseStatusCode in the PerformanceRecord struct.
    • Updated the MarkFailed method to set ResponseStatusCode.
    • Modified RecordPerformance to log ResponseStatusCode.
  • internal/server/biz/channel_metrics_test.go
    • Updated test cases to use ResponseStatusCode instead of ErrorStatusCode in PerformanceRecord.
  • internal/server/biz/request.go
    • Modified UpdateRequestExecutionCanceled and UpdateRequestExecutionFailed to accept an optional ExecutionErrorInfo struct.
    • Introduced ExecutionErrorInfo struct to encapsulate error details, including StatusCode.
    • Updated UpdateRequestExecutionStatus to apply the responseStatusCode from ExecutionErrorInfo.
    • Modified UpdateRequestExecutionStatusFromError to pass nil for ExecutionErrorInfo.
  • internal/server/biz/system_proxy.go
    • Added a blank line for minor formatting consistency.
  • internal/server/gql/ent.graphql
    • Added responseStatusCode to the RequestExecution GraphQL type with a description.
    • Included responseStatusCode and its predicates in the RequestExecutionWhereInput GraphQL input type.
  • internal/server/gql/system.resolvers.go
    • Reordered imports for github.com/samber/lo.
    • Moved SaveProxyPreset and DeleteProxyPreset resolvers to the mutationResolver struct.
    • Updated the return type of ProxyPresets to []*biz.ProxyPreset.
  • internal/server/orchestrator/candidates_loadbalance_test.go
    • Updated test cases to use ResponseStatusCode instead of ErrorStatusCode in PerformanceRecord.
  • internal/server/orchestrator/lb_strategy_bp_test.go
    • Updated test cases to use ResponseStatusCode instead of ErrorStatusCode in PerformanceRecord.
  • internal/server/orchestrator/load_balancer_test.go
    • Updated test cases to use ResponseStatusCode instead of ErrorStatusCode in PerformanceRecord.
  • internal/server/orchestrator/request_execution.go
    • Modified OnOutboundRawError to pass ExecutionErrorInfo when updating request execution status.
    • Added ExtractErrorInfo function to extract HTTP status code from httpclient.Error.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature by adding the responseStatusCode to failed request executions, which will greatly aid in debugging. The changes are well-implemented across the stack, from the database schema and backend services to the GraphQL API and frontend components. The refactoring of ErrorStatusCode to ResponseStatusCode for consistency is also a welcome improvement. I've included a couple of suggestions to further enhance the UI presentation of errors and to improve the robustness of error status handling in the backend.

Comment on lines +676 to 691
{(execution.errorMessage || (execution.status === 'failed' && execution.responseStatusCode)) && (
<div className='bg-destructive/5 border-destructive/20 space-y-3 rounded-lg border p-4'>
<span className='text-destructive flex items-center gap-2 text-sm font-semibold'>
<FileText className='h-4 w-4' />
{t('common.messages.errorMessage')}
</span>
<p className='text-destructive bg-destructive/10 rounded border p-3 text-sm'>{execution.errorMessage}</p>
<div className='flex items-center justify-between'>
<span className='text-destructive flex items-center gap-2 text-sm font-semibold'>
<FileText className='h-4 w-4' />
{t('common.messages.errorMessage')}
</span>
{execution.status === 'failed' && execution.responseStatusCode && (
<Badge variant='destructive'>HTTP {execution.responseStatusCode}</Badge>
)}
</div>
{execution.errorMessage && (
<p className='text-destructive bg-destructive/10 rounded border p-3 text-sm'>{execution.errorMessage}</p>
)}
</div>
)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the case where execution.errorMessage is empty but execution.responseStatusCode is present, the UI will display the "Error Message" title without any message body, which could be confusing. It would be better to handle this case explicitly, for example by showing only the status code badge or a more generic message.

                              {execution.errorMessage ? (
                                <div className='bg-destructive/5 border-destructive/20 space-y-3 rounded-lg border p-4'>
                                  <div className='flex items-center justify-between'>
                                    <span className='text-destructive flex items-center gap-2 text-sm font-semibold'>
                                      <FileText className='h-4 w-4' />
                                      {t('common.messages.errorMessage')}
                                    </span>
                                    {execution.status === 'failed' && execution.responseStatusCode && (
                                      <Badge variant='destructive'>HTTP {execution.responseStatusCode}</Badge>
                                    )}
                                  </div>
                                  <p className='text-destructive bg-destructive/10 rounded border p-3 text-sm'>{execution.errorMessage}</p>
                                </div>
                              ) : (
                                execution.status === 'failed' &&
                                execution.responseStatusCode && (
                                  <div className='bg-destructive/5 border-destructive/20 rounded-lg p-4'>
                                    <Badge variant='destructive'>HTTP {execution.responseStatusCode}</Badge>
                                  </div>
                                )
                              )}

}

return s.UpdateRequestExecutionStatus(ctx, executionID, status, rawErr.Error())
return s.UpdateRequestExecutionStatus(ctx, executionID, status, rawErr.Error(), nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This call passes nil for errorInfo, which means if rawErr is an *httpclient.Error, the status code information will be lost. Consider extracting the error info from rawErr here and passing it to UpdateRequestExecutionStatus. This would likely involve moving the new ExtractErrorInfo function from the orchestrator package to the biz package to make it reusable and avoid a circular dependency.

Comment on lines +211 to +221
// ExtractErrorInfo extracts HTTP status code and sanitized response body from error.
func ExtractErrorInfo(err error) *biz.ExecutionErrorInfo {
httpErr, ok := xerrors.As[*httpclient.Error](err)
if !ok {
return nil
}

return &biz.ExecutionErrorInfo{
StatusCode: &httpErr.StatusCode,
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve code organization and reusability, consider moving ExtractErrorInfo to the biz package. This would allow other parts of the business logic, such as UpdateRequestExecutionStatusFromError in internal/server/biz/request.go, to use this utility function without creating circular dependencies.

@looplj looplj merged commit 47411c2 into release/v0.9.x Mar 16, 2026
2 checks passed
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