fix(directory): surface BTP error bodies via specifyAPIError#731
fix(directory): surface BTP error bodies via specifyAPIError#731maximilianbraun wants to merge 3 commits into
Conversation
maximilianbraun
left a comment
There was a problem hiding this comment.
internal/clients/directory/directory_test.go:880 — Drop the local create409Error; it is a verbatim copy of subaccount_test.go's helper (same unsafe-pointer reflection over GenericOpenAPIError's unexported fields). Move one copy to internal/testutils (or wherever the BTP test helpers live) and import it from both packages — duplicating a reflect/unsafe trick guarantees one of them rots silently when the SDK regenerates.
maximilianbraun
left a comment
There was a problem hiding this comment.
Helper is appropriately minimal: every parameter has a caller using it, the empty-message branch lets the original code-only call site stay one-liner, and the regeneration-rot warning is the right ceiling note for unsafe-reflection. Subaccount_test.go edit is the deduplication itself, not scope creep. Lean.
Reviewer flagged 4 inline reflect+unsafe copies that all set the unexported `body` field on a *xsuaa.GenericOpenAPIError. Extract to internal/testutils/openapi_errors_xsuaa.go::NewXsuaaAPIError so each test site collapses to one line. Filed under a separate filename from PR #731's openapi_errors.go to avoid a rebase collision; the two helpers can be unified once both branches land.
939efc9 to
51e8cde
Compare
Summary
DeleteDirectoryandUpdateDirectorynon-404 paths through the existingspecifyAPIErrorhelper so 409/5xx BTP error bodies surface in theSyncedcondition instead of bare transport errors.Test plan
go build ./... && go vet ./...go test -race -count=1 ./internal/clients/directory/... ./internal/controller/account/directory/...DeleteAPI409SurfacesErrorunit test exercising aGenericOpenAPIErrorwithApiExceptionResponseObjectmodel.