Migrate off deprecated trait profile/status attributes - #84
Conversation
baton-sdk v0.20.6 moved `profile`, `status`, and `created_at` off the trait
messages onto attributes on `Resource`, deprecating the trait-level options and
getters. staticcheck flags every remaining call with `SA1019`, so `verify / lint`
is red on `main`.
This migrates the connector to the resource-level API:
- `With{User,Group,Role,App}Profile` -> `WithResourceProfile`
- `WithStatus` / `WithDetailedStatus` -> `WithResourceStatus`
- `WithCreatedAt` / `WithSecretCreatedAt` -> `WithResourceCreatedAt`
- trait `GetProfile()` / `GetStatus()` reads -> the equivalent read on the resource
The option type changes from a `*TraitOption` to a `ResourceOption`, so the calls
move out of the trait slice and into the variadic tail of the `New*Resource` call.
The two status enums are numerically identical, so the values map 1:1. Non-deprecated
trait data (login, aliases, emails, secret type/expiry) is untouched.
No behavioural change intended: the deprecated options already populated the
resource-level fields. `golangci-lint run ./...` reports 0 issues after this
change, and the package tests pass.
| rs.WithAccountType(v2.UserTrait_ACCOUNT_TYPE_HUMAN), | ||
| }, rs.WithAnnotation(annos)) | ||
| }, | ||
| rs.WithResourceCreatedAt(proto.GetCreatedTime().AsTime()), rs.WithAnnotation(annos)) |
There was a problem hiding this comment.
🟡 Suggestion: When CreatedTime is unset, GetCreatedTime().AsTime() yields 1970-01-01, so the resource gets an explicit (and wrong) created_at rather than being left unset — HasCreatedAt() then reports true. This is pre-existing behavior carried over from WithCreatedAt, not a regression, but since the call is being rewritten it's a cheap place to guard: only append rs.WithResourceCreatedAt(...) when proto.GetCreatedTime() != nil. Same applies at line 59 for service accounts. (confidence: medium)
Connector PR Review: Migrate off deprecated trait profile/status attributesBlocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review SummaryScanned the full PR diff for security and correctness. The change is a single file ( Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
baton-sdk v0.20.6 moved
profile,status, andcreated_atoff the traitmessages onto attributes on
Resource, deprecating the trait-level options andgetters. staticcheck flags every remaining call with
SA1019, soverify / lintis red on
main.This migrates the connector to the resource-level API:
With{User,Group,Role,App}Profile->WithResourceProfileWithStatus/WithDetailedStatus->WithResourceStatusWithCreatedAt/WithSecretCreatedAt->WithResourceCreatedAtGetProfile()/GetStatus()reads -> the equivalent read on the resourceThe option type changes from a
*TraitOptionto aResourceOption, so the callsmove out of the trait slice and into the variadic tail of the
New*Resourcecall.The two status enums are numerically identical, so the values map 1:1. Non-deprecated
trait data (login, aliases, emails, secret type/expiry) is untouched.
No behavioural change intended: the deprecated options already populated the
resource-level fields.
golangci-lint run ./...reports 0 issues after thischange, and the package tests pass.