Repository navigation
fix(clients): treat only GitLab JSON 404s as not found - #440
Merged
Merged
Conversation
Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
…bserve approvalrules ErrGet404 had no external name, so Observe returned before calling GitLab. project serviceaccounts had no 404 case. Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
BoxBoxJason
approved these changes
Oct 15, 2026
dariozachow
approved these changes
Oct 19, 2026
dariozachow
approved these changes
Oct 19, 2026
IsResponseNotFound now requires a JSON 404. Update the fixtures of controllers merged after this branch was cut. Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
henrysachs
added a commit
that referenced
this pull request
Oct 20, 2026
IsResponseNotFound now requires a JSON Content-Type (#440). Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Why
IsResponseNotFoundreturned true for any 404. A proxy or ingress in front of GitLab also returns a 404 when its backend is down. The provider then called Create, which made duplicate resources, or it dropped the finalizer on Delete. GitLab renders API 404s as JSON, so this change treats a 404 as "not found" only when its media type isapplication/json.What changed
IsResponseNotFoundrequires status 404 and media typeapplication/json. It returns false for a nilresor a nilres.Response.IsResponseNotFoundinstead ofIsErrorLdapGroupLinkNotFound, which is removed. client-go v3 returns the same404 Not Founderror for every 404, so that string check matched proxy 404s too.Content-Type: application/json. New cases cover text/plain and text/html 404s.Scope
IsResponseNotFoundcaller. A non-JSON 404 now returns an error, so the provider retries on the next reconcile.Linked SAML group link not found) never matches the client-go v3 404 error. A SAML link deleted outside the provider stays in an error state and is not recreated. That bug already exists and is not caused by this change. Follow-up.Merge order
Merge this PR late, after the open feature PRs (#430, #432–#437, #439, #442, #443) and before #441. Their new controller tests build 404 fixtures without
Content-Type. With this change they would fail. Once those PRs are in master, this PR gets rebased and also setsContent-Type: application/jsonon their 404 fixtures, as it already does for the existing tests. A PR from that list that is not merged by then gets the header on its own branch instead.Blast Radius
All controllers that detect "not found" with
IsResponseNotFound. A real GitLab 404 behaves as before. A 404 from a proxy now showsSynced=Falseuntil GitLab comes back.Verification
go test ./pkg/... ./apis/...and golangci-lint on the changed packages pass. The new tests fail on master and pass with the fix.404 application/json, and the provider recreated the variable within 5 s.text/plain404 for GETs and forwards POSTs: on master the Badge MR got a second badge (ids 1 and 2) and its external-name moved to 2. With the fix, the proxy logged 0 POSTs, the MR showedobserve failed: cannot get Gitlab badge: 404 Not Found, and GitLab kept one badge.Fixes #425
I have:
make reviewable testto ensure this PR is ready for review.How has this code been tested
See Verification.