From b518a912116c03a1ae366c648dfcb43225b33462 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Mar 2026 15:09:32 +0000 Subject: [PATCH] Strip triggerType from notification rule update requests The DependencyTrack API now rejects updates that include triggerType with "Trigger type can not be changed" (HTTP 400), even when the value hasn't changed. Strip the field from POST requests to the notification rule endpoint via the HTTP transport, matching the existing pattern used for ProjectProperty deletion fixes. https://claude.ai/code/session_011HxZxkTEg9c9LAd3GBQbDS --- internal/provider/http_client.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/internal/provider/http_client.go b/internal/provider/http_client.go index 0a10cef..08694ff 100644 --- a/internal/provider/http_client.go +++ b/internal/provider/http_client.go @@ -19,7 +19,8 @@ const ( ) var ( - projectPropertyURLRegex = regexp.MustCompile("^/api/v1/project/" + uuidRegex + "/property$") + projectPropertyURLRegex = regexp.MustCompile("^/api/v1/project/" + uuidRegex + "/property$") + notificationRuleURLPattern = "/api/v1/notification/rule" ) type ( @@ -56,6 +57,24 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) { } req.Body = io.NopCloser(bodyBuf) } + // The DependencyTrack API rejects updates that include triggerType + // ("Trigger type can not be changed"), even if the value hasn't changed. + // Strip it from notification rule update (POST) requests. + if req.URL.Path == notificationRuleURLPattern && req.Method == http.MethodPost { + var body map[string]json.RawMessage + err := json.NewDecoder(req.Body).Decode(&body) + if err != nil { + return nil, err + } + delete(body, "triggerType") + bodyBuf := new(bytes.Buffer) + err = json.NewEncoder(bodyBuf).Encode(body) + if err != nil { + return nil, err + } + req.Body = io.NopCloser(bodyBuf) + req.ContentLength = int64(bodyBuf.Len()) + } // End patching. return t.inner.RoundTrip(req) }