Skip to content

Commit

Permalink
Merge pull request #4 from thedadams/ensure-workspace-ids-on-replace
Browse files Browse the repository at this point in the history
fix: ensure that knowledge and workspace ids are set on replace
  • Loading branch information
ibuildthecloud authored Sep 11, 2024
2 parents 44eaeff + 92acca8 commit 5cc59f3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/api/handlers/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (a *AgentHandler) Delete(ctx context.Context, req api.Request) error {
agent v2.Agent
)

if err := req.Get(&agent, id); apierrors.IsNotFound(err) {
var httpErr *api.ErrHTTP
if err := req.Get(&agent, id); errors.As(err, &httpErr) && httpErr.Code == http.StatusNotFound {
return nil
} else if err != nil {
return err
Expand Down Expand Up @@ -107,6 +108,9 @@ func (a *AgentHandler) Create(ctx context.Context, req api.Request) error {
return err
} else if !replace {
return apierrors.NewAlreadyExists(v2.SchemeGroupVersion.WithResource("agents").GroupResource(), spec.Manifest.ID)
} else {
spec.WorkspaceID = agent.Spec.WorkspaceID
spec.KnowledgeWorkspaceID = agent.Spec.KnowledgeWorkspaceID
}

agent = v2.Agent{
Expand Down

0 comments on commit 5cc59f3

Please sign in to comment.