Skip to content

Fix/project update issues - #122

Open
pancysingla-creator wants to merge 4 commits into
mainfrom
fix/project-update-issues
Open

pancysingla-creator wants to merge 4 commits into
mainfrom
fix/project-update-issues

Conversation

@pancysingla-creator

@pancysingla-creator pancysingla-creator commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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 labels is null, the API leaves the field out and the confirm dialog crashes on labels.map. The page shows "Something Went Wrong" and no PUT is sent.

Fix: default labels to an empty list in UpdateProjectInfoModal.

Before After
img_v3_0217i_c2b19b3d-a264-4e3e-8c7f-4b21120c1chu img_v3_0217i_a5bb9d90-3a31-4ae7-ad27-8bf75a15e3hu

2. User Roles / Project Info: unclear 500 when a webhook rejects the update

When the OnProjectUpdated webhook replies with a 4xx (e.g. 404 team not found), the API returned a 500 with the raw webhook response, which doesn't tell the user what to fix.

Fix: webhook failures can come from any endpoint the webhook calls, not just team/stream checks, so the response stays a 500. Instead, the message now tells the user to contact the platform owner and includes a reference ID, so the platform owner can find the matching log line for the full error.

Before After
image img_v3_0217p_4b1e6137-80b0-4359-9a21-4517cd72e2hu

pancysingla-creator and others added 2 commits November 18, 2026 14:08
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 anantadwi13 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw i have some concerns below. wdyt?

Comment thread api/pkg/webhooks/client.go Outdated

"github.com/avast/retry-go/v4"
"github.com/caraml-dev/mlp/api/log"
apperror "github.com/caraml-dev/mlp/api/pkg/errors"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer this package shouldn't import another package, and let's use its internal error instead in errors.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, sure!

Comment thread api/service/projects_service.go Outdated
"and change them on the Project Info page if needed",
err, project.Team, project.Stream,
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a few clarifications regarding this:

  1. 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?

  2. 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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. ok, appending directly to webhook error should work as well
  2. afaik, we dont return any req id. since changing all endpoints is not a good idea, yes, i believe we can generate uuid per webhook call and append it to the error message

@anantadwi13 anantadwi13 Nov 24, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this one is a good place to append the message

msg: "error invoking webhook",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I'll make the changes!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the fixes mentioned, please let me know if there is any issue!

Comment thread api/pkg/webhooks/client.go Outdated
Comment on lines +104 to +108
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),
))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding my comment here https://github.com/caraml-dev/mlp/pull/122/changes#r4623239246

this seems like not necessary

pancysingla-creator and others added 2 commits November 24, 2026 18:05
…e 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
manual — 9971d02d Deployed Nov 24, 2026 by pancysingla-creator via publish-docker #452
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants