Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e3fbbb91
authored
Nov 29, 2025
by
Seefs
Committed by
GitHub
Nov 29, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2329 from mfzzf/fix/aws-anthropic-http-err-code
fix(aws): extract HTTP status code from AWS SDK errors
parents
88bdf948
f928e9d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
relay/channel/aws/relay-aws.go
+17
-3
No files found.
relay/channel/aws/relay-aws.go
View file @
e3fbbb91
...
...
@@ -25,6 +25,17 @@ import (
"github.com/aws/smithy-go/auth/bearer"
)
// getAwsErrorStatusCode extracts HTTP status code from AWS SDK error
func
getAwsErrorStatusCode
(
err
error
)
int
{
// Check for HTTP response error which contains status code
var
httpErr
interface
{
HTTPStatusCode
()
int
}
if
errors
.
As
(
err
,
&
httpErr
)
{
return
httpErr
.
HTTPStatusCode
()
}
// Default to 500 if we can't determine the status code
return
http
.
StatusInternalServerError
}
func
newAwsClient
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
)
(
*
bedrockruntime
.
Client
,
error
)
{
var
(
httpClient
*
http
.
Client
...
...
@@ -173,7 +184,8 @@ func awsHandler(c *gin.Context, info *relaycommon.RelayInfo, a *Adaptor) (*types
awsResp
,
err
:=
a
.
AwsClient
.
InvokeModel
(
c
.
Request
.
Context
(),
a
.
AwsReq
.
(
*
bedrockruntime
.
InvokeModelInput
))
if
err
!=
nil
{
return
types
.
NewOpenAIError
(
errors
.
Wrap
(
err
,
"InvokeModel"
),
types
.
ErrorCodeAwsInvokeError
,
http
.
StatusInternalServerError
),
nil
statusCode
:=
getAwsErrorStatusCode
(
err
)
return
types
.
NewOpenAIError
(
errors
.
Wrap
(
err
,
"InvokeModel"
),
types
.
ErrorCodeAwsInvokeError
,
statusCode
),
nil
}
claudeInfo
:=
&
claude
.
ClaudeResponseInfo
{
...
...
@@ -199,7 +211,8 @@ func awsHandler(c *gin.Context, info *relaycommon.RelayInfo, a *Adaptor) (*types
func
awsStreamHandler
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
a
*
Adaptor
)
(
*
types
.
NewAPIError
,
*
dto
.
Usage
)
{
awsResp
,
err
:=
a
.
AwsClient
.
InvokeModelWithResponseStream
(
c
.
Request
.
Context
(),
a
.
AwsReq
.
(
*
bedrockruntime
.
InvokeModelWithResponseStreamInput
))
if
err
!=
nil
{
return
types
.
NewOpenAIError
(
errors
.
Wrap
(
err
,
"InvokeModelWithResponseStream"
),
types
.
ErrorCodeAwsInvokeError
,
http
.
StatusInternalServerError
),
nil
statusCode
:=
getAwsErrorStatusCode
(
err
)
return
types
.
NewOpenAIError
(
errors
.
Wrap
(
err
,
"InvokeModelWithResponseStream"
),
types
.
ErrorCodeAwsInvokeError
,
statusCode
),
nil
}
stream
:=
awsResp
.
GetStream
()
defer
stream
.
Close
()
...
...
@@ -238,7 +251,8 @@ func handleNovaRequest(c *gin.Context, info *relaycommon.RelayInfo, a *Adaptor)
awsResp
,
err
:=
a
.
AwsClient
.
InvokeModel
(
c
.
Request
.
Context
(),
a
.
AwsReq
.
(
*
bedrockruntime
.
InvokeModelInput
))
if
err
!=
nil
{
return
types
.
NewError
(
errors
.
Wrap
(
err
,
"InvokeModel"
),
types
.
ErrorCodeChannelAwsClientError
),
nil
statusCode
:=
getAwsErrorStatusCode
(
err
)
return
types
.
NewOpenAIError
(
errors
.
Wrap
(
err
,
"InvokeModel"
),
types
.
ErrorCodeAwsInvokeError
,
statusCode
),
nil
}
// 解析Nova响应
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment