Repository navigation
Fix/project update issues - #122
pancysingla-creator wants to merge 2 commits into
Conversation
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
anantadwi13
left a comment
There was a problem hiding this comment.
btw i have some concerns below. wdyt?
|
|
||
| "github.com/avast/retry-go/v4" | ||
| "github.com/caraml-dev/mlp/api/log" | ||
| apperror "github.com/caraml-dev/mlp/api/pkg/errors" |
There was a problem hiding this comment.
i prefer this package shouldn't import another package, and let's use its internal error instead in errors.go
There was a problem hiding this comment.
Alright, sure!
| "and change them on the Project Info page if needed", | ||
| err, project.Team, project.Stream, | ||
| ) | ||
| } |
There was a problem hiding this comment.
btw, somehow i prefer we are not changing this logic. it should be still returning 500 error instead of 4xx (apperror.NewInvalidArgumentErrorf), because it is the server internal communication with webhook server, and it can be used to call any endpoints (not just related to team & stream management). that means asking the user to check team & stream are valid might lead to misinformation
also, the user is expected not to know this kind of issue. i prefer the error message tells the user to contact the platform owner, and the platform owner add some FAQ docs to help user tackle this kind of issue.
nice to have: adding request id or any reference id to the error message to make debugging process easier
There was a problem hiding this comment.
I had a few clarifications regarding this:
-
QA report mentioned we want the user to see 404 instead of 500, and we should wrap a 4xx response from a webhook as apperror.InvalidArgumentError or apperror.NotFoundError, but as you mentioned above should it be kept 500? Should we append "Please contact the platform owner" directly in webhooks/errors.go (so the API response carries it), or handle that phrasing on the UI side? Is there any specific support channel we should link to in that case?
-
For request id or any reference id part, does mlp already attach a request ID or headers or should we generate a UUID per webhook call and append it to the error message?
| 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), | ||
| )) | ||
| } |
There was a problem hiding this comment.
regarding my comment here https://github.com/caraml-dev/mlp/pull/122/changes#r4623239246
this seems like not necessary
Description
Fixes two errors when updating a project from the console.
1. Project Info: Submit crashes when the project has no labels
If a project's
labelsisnull, the API leaves the field out and the confirm dialog crashes onlabels.map. The page shows "Something Went Wrong" and no PUT is sent.Fix: default
labelsto an empty list inUpdateProjectInfoModal.2. User Roles / Project Info: unclear 500 when a webhook rejects the update
When the
OnProjectUpdatedwebhook replies with a 4xx (e.g. 404team not found), the API returned a 500 with the raw webhook response, which doesn't tell the user what to fix.Fix:
UpdateProject: adds the project's team and stream to that error, so the API returns a 400 that tells the user what to check.