From 50c3a80ace1d7336a0f550c3afb13e5486f483ec Mon Sep 17 00:00:00 2001 From: Pancy Singla Date: Thu, 12 Nov 2026 18:52:27 +0530 Subject: [PATCH 1/4] fix(ui): guard null labels in UpdateProjectInfoModal Projects whose labels are null (or omitted by the API) crashed the Project Info confirm dialog on Submit with "Cannot read properties of undefined (reading 'map')", so no PUT request was sent. Default both the original and the edited labels to an empty list before mapping. Co-Authored-By: Claude Opus 5.5 --- .../project_setting/project_info/UpdateProjectInfoModal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/packages/app/src/project_setting/project_info/UpdateProjectInfoModal.js b/ui/packages/app/src/project_setting/project_info/UpdateProjectInfoModal.js index 32521819..85a83f6e 100644 --- a/ui/packages/app/src/project_setting/project_info/UpdateProjectInfoModal.js +++ b/ui/packages/app/src/project_setting/project_info/UpdateProjectInfoModal.js @@ -75,11 +75,11 @@ const UpdateProjectInfoModal = ({ } ]; - const rows = project.labels.map(label => ({ + const rows = (project.labels || []).map(label => ({ ...label })); - const originalRows = originalProject.labels.map(label => ({ + const originalRows = (originalProject.labels || []).map(label => ({ ...label })); From e0338a5377535f3c1ddb70eda0d0fcc22e6eafb9 Mon Sep 17 00:00:00 2001 From: Pancy Singla Date: Wed, 18 Nov 2026 14:29:43 +0530 Subject: [PATCH 2/4] fix(api): return the webhook's message when it rejects a project update When a webhook replies with a 4xx, the project update now fails with a 400 that carries the webhook's own error message plus the project's team and stream, instead of a 500 with the raw response. For example, a team that is not registered in Warden now reads: webhook_1 rejected the request (status 404): team not found (project team "ds_identity", stream "ds_identity"). Check that the team and stream are valid, and change them on the Project Info page if needed - Webhook client: a 4xx reply becomes an InvalidArgumentError with the webhook's message, and is no longer retried. 5xx replies are unchanged. - UpdateProject: add the project's team and stream to that error, and log the correct event name. Co-Authored-By: Claude Opus 5.5 --- api/pkg/webhooks/client.go | 8 ++++++++ api/pkg/webhooks/errors.go | 20 +++++++++++++++++++- api/service/projects_service.go | 11 ++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/api/pkg/webhooks/client.go b/api/pkg/webhooks/client.go index 526be0ca..9a70af29 100644 --- a/api/pkg/webhooks/client.go +++ b/api/pkg/webhooks/client.go @@ -54,6 +54,7 @@ import ( "github.com/avast/retry-go/v4" "github.com/caraml-dev/mlp/api/log" + apperror "github.com/caraml-dev/mlp/api/pkg/errors" "github.com/go-playground/validator/v10" ) @@ -98,6 +99,13 @@ func (g *simpleWebhookClient) Invoke(ctx context.Context, payload []byte) ([]byt if err != nil { return err } + // A 4xx reply means the webhook rejected the request, so retrying won't help. + // Return the webhook's own message as an invalid-argument error so the user sees it. + if resp.StatusCode >= http.StatusBadRequest && resp.StatusCode < http.StatusInternalServerError { + return retry.Unrecoverable(apperror.NewInvalidArgumentErrorf( + "%s rejected the request (status %d): %s", g.Name, resp.StatusCode, webhookErrorMessage(content), + )) + } if err := validateWebhookResponse(content); err != nil { return err } diff --git a/api/pkg/webhooks/errors.go b/api/pkg/webhooks/errors.go index f8287f0c..aea7ccda 100644 --- a/api/pkg/webhooks/errors.go +++ b/api/pkg/webhooks/errors.go @@ -1,6 +1,10 @@ package webhooks -import "fmt" +import ( + "encoding/json" + "fmt" + "strings" +) type WebhookError struct { msg string @@ -27,3 +31,17 @@ func (e *WebhookError) Is(target error) bool { _, ok := target.(*WebhookError) return ok } + +// webhookErrorMessage returns the "error" field of a JSON error body. +func webhookErrorMessage(content []byte) string { + var body struct { + Error string `json:"error"` + } + if err := json.Unmarshal(content, &body); err == nil && body.Error != "" { + return body.Error + } + if msg := strings.TrimSpace(string(content)); msg != "" { + return msg + } + return "no error message returned" +} diff --git a/api/service/projects_service.go b/api/service/projects_service.go index df8fc586..f9b19970 100644 --- a/api/service/projects_service.go +++ b/api/service/projects_service.go @@ -20,6 +20,7 @@ import ( "github.com/caraml-dev/mlp/api/log" "github.com/caraml-dev/mlp/api/models" "github.com/caraml-dev/mlp/api/pkg/authz/enforcer" + apperror "github.com/caraml-dev/mlp/api/pkg/errors" "github.com/caraml-dev/mlp/api/pkg/webhooks" ) @@ -171,7 +172,15 @@ func (service *projectsService) UpdateProject(ctx context.Context, project *mode return nil }, func(err error) error { // Print error and return - log.Errorf("error calling webhook - %s, err: %s", ProjectCreatedEvent, err.Error()) + log.Errorf("error calling webhook - %s, err: %s", ProjectUpdatedEvent, err.Error()) + // The webhook rejected the request: add the project's team and stream so the user knows what to check. + if errors.Is(err, &apperror.InvalidArgumentError{}) { + return apperror.NewInvalidArgumentErrorf( + "%s (project team %q, stream %q). Check that the team and stream are valid, "+ + "and change them on the Project Info page if needed", + err, project.Team, project.Stream, + ) + } return err }, ) From 34d34a3d6c5fedafef82e3519e56effe801f2ff6 Mon Sep 17 00:00:00 2001 From: Pancy Singla Date: Tue, 24 Nov 2026 18:05:22 +0530 Subject: [PATCH 3/4] fix(api): keep webhook failures as 500 and ask the user to contact the platform owner Webhooks can call any endpoint, so a webhook failure is a server-side problem, not invalid user input. Revert the 4xx-to-400 mapping and keep returning 500, with a message that tells the user to contact the platform owner. - Webhook client: remove the 4xx special case and the apperror import. - WebhookError: append "Please contact the platform owner" to the message. - UpdateProject: remove the team/stream hint; keep the corrected log event name. Co-Authored-By: Claude Opus 5.5 --- api/pkg/webhooks/client.go | 8 -------- api/pkg/webhooks/errors.go | 22 ++-------------------- api/service/projects_service.go | 9 --------- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/api/pkg/webhooks/client.go b/api/pkg/webhooks/client.go index 9a70af29..526be0ca 100644 --- a/api/pkg/webhooks/client.go +++ b/api/pkg/webhooks/client.go @@ -54,7 +54,6 @@ import ( "github.com/avast/retry-go/v4" "github.com/caraml-dev/mlp/api/log" - apperror "github.com/caraml-dev/mlp/api/pkg/errors" "github.com/go-playground/validator/v10" ) @@ -99,13 +98,6 @@ func (g *simpleWebhookClient) Invoke(ctx context.Context, payload []byte) ([]byt if err != nil { return err } - // A 4xx reply means the webhook rejected the request, so retrying won't help. - // Return the webhook's own message as an invalid-argument error so the user sees it. - if resp.StatusCode >= http.StatusBadRequest && resp.StatusCode < http.StatusInternalServerError { - return retry.Unrecoverable(apperror.NewInvalidArgumentErrorf( - "%s rejected the request (status %d): %s", g.Name, resp.StatusCode, webhookErrorMessage(content), - )) - } if err := validateWebhookResponse(content); err != nil { return err } diff --git a/api/pkg/webhooks/errors.go b/api/pkg/webhooks/errors.go index aea7ccda..b70ac59f 100644 --- a/api/pkg/webhooks/errors.go +++ b/api/pkg/webhooks/errors.go @@ -1,10 +1,6 @@ package webhooks -import ( - "encoding/json" - "fmt" - "strings" -) +import "fmt" type WebhookError struct { msg string @@ -13,7 +9,7 @@ type WebhookError struct { func NewWebhookError(err error) *WebhookError { return &WebhookError{ - msg: "error invoking webhook", + msg: "error invoking webhook. Please contact the platform owner", err: err, } } @@ -31,17 +27,3 @@ func (e *WebhookError) Is(target error) bool { _, ok := target.(*WebhookError) return ok } - -// webhookErrorMessage returns the "error" field of a JSON error body. -func webhookErrorMessage(content []byte) string { - var body struct { - Error string `json:"error"` - } - if err := json.Unmarshal(content, &body); err == nil && body.Error != "" { - return body.Error - } - if msg := strings.TrimSpace(string(content)); msg != "" { - return msg - } - return "no error message returned" -} diff --git a/api/service/projects_service.go b/api/service/projects_service.go index f9b19970..5e1d7701 100644 --- a/api/service/projects_service.go +++ b/api/service/projects_service.go @@ -20,7 +20,6 @@ import ( "github.com/caraml-dev/mlp/api/log" "github.com/caraml-dev/mlp/api/models" "github.com/caraml-dev/mlp/api/pkg/authz/enforcer" - apperror "github.com/caraml-dev/mlp/api/pkg/errors" "github.com/caraml-dev/mlp/api/pkg/webhooks" ) @@ -173,14 +172,6 @@ func (service *projectsService) UpdateProject(ctx context.Context, project *mode }, func(err error) error { // Print error and return log.Errorf("error calling webhook - %s, err: %s", ProjectUpdatedEvent, err.Error()) - // The webhook rejected the request: add the project's team and stream so the user knows what to check. - if errors.Is(err, &apperror.InvalidArgumentError{}) { - return apperror.NewInvalidArgumentErrorf( - "%s (project team %q, stream %q). Check that the team and stream are valid, "+ - "and change them on the Project Info page if needed", - err, project.Team, project.Stream, - ) - } return err }, ) From 9971d02df35443d8a251df22e1e7616b7b258e93 Mon Sep 17 00:00:00 2001 From: Pancy Singla Date: Tue, 24 Nov 2026 18:11:54 +0530 Subject: [PATCH 4/4] fix(api): add a reference id to webhook errors MLP does not return a request id, so each WebhookError now gets its own UUID. It is part of the error message, so the user can quote it to the platform owner, who can find the matching log line. Co-Authored-By: Claude Opus 5.5 --- api/pkg/webhooks/errors.go | 19 ++++++++++++++----- go.mod | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/pkg/webhooks/errors.go b/api/pkg/webhooks/errors.go index b70ac59f..edf9ec35 100644 --- a/api/pkg/webhooks/errors.go +++ b/api/pkg/webhooks/errors.go @@ -1,16 +1,25 @@ package webhooks -import "fmt" +import ( + "fmt" + + "github.com/google/uuid" +) type WebhookError struct { - msg string - err error + msg string + err error + ReferenceID string } +// NewWebhookError wraps a failed webhook call. Each error gets its own reference id, which is part of +// the message, so a user can quote it and the platform owner can find the matching log line. func NewWebhookError(err error) *WebhookError { + referenceID := uuid.New().String() return &WebhookError{ - msg: "error invoking webhook. Please contact the platform owner", - err: err, + msg: fmt.Sprintf("error invoking webhook. Please contact the platform owner (reference id: %s)", referenceID), + err: err, + ReferenceID: referenceID, } } diff --git a/go.mod b/go.mod index e6da7445..f4b57f78 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/go-playground/validator/v10 v10.11.1 github.com/golang-migrate/migrate/v4 v4.11.0 github.com/google/go-cmp v0.5.9 + github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.7.4 github.com/hashicorp/vault/api v1.9.0 github.com/hashicorp/vault/api/auth/gcp v0.4.0 @@ -87,7 +88,6 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.1.0 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect