Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
22ccdd74
Unverified
Commit
22ccdd74
authored
Sep 18, 2025
by
Jeffrey Morgan
Committed by
GitHub
Sep 18, 2025
Browse files
server: add unauthorized error to remote chat handler (#12338)
parent
0c3d0e75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
server/routes.go
server/routes.go
+18
-1
No files found.
server/routes.go
View file @
22ccdd74
...
...
@@ -259,7 +259,10 @@ func (s *Server) GenerateHandler(c *gin.Context) {
c
.
JSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"error"
:
"error getting public key"
})
return
}
c
.
JSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"public_key"
:
pk
})
c
.
JSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"error"
:
"unauthorized"
,
"public_key"
:
pk
,
})
return
}
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
...
...
@@ -1810,6 +1813,20 @@ func (s *Server) ChatHandler(c *gin.Context) {
client
:=
api
.
NewClient
(
remoteURL
,
http
.
DefaultClient
)
err
=
client
.
Chat
(
c
,
&
req
,
fn
)
if
err
!=
nil
{
var
sErr
api
.
AuthorizationError
if
errors
.
As
(
err
,
&
sErr
)
&&
sErr
.
StatusCode
==
http
.
StatusUnauthorized
{
pk
,
pkErr
:=
auth
.
GetPublicKey
()
if
pkErr
!=
nil
{
slog
.
Error
(
"couldn't get public key"
,
"error"
,
pkErr
)
c
.
JSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"error"
:
"error getting public key"
})
return
}
c
.
JSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"error"
:
"unauthorized"
,
"public_key"
:
pk
,
})
return
}
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
...
...
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