Migrate off deprecated trait profile/status attributes - #50
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.
| user.ID, | ||
| userTraits, | ||
| rs.WithResourceProfile(profile), | ||
| rs.WithResourceStatus(v2.Status_ResourceStatus(userStatus), ""), |
There was a problem hiding this comment.
🟡 Suggestion (medium confidence): the enum cast is correct today — UserTrait_Status_Status and Status_ResourceStatus are both 0/1/2/3 for UNSPECIFIED/ENABLED/DISABLED/DELETED, and the SDK does the same cast internally in syncUserTraitToResource. But keeping userStatus typed as the deprecated v2.UserTrait_Status_Status means the connector still depends on the deprecated enum and needs a numeric cross-enum cast that would silently break if the two enums ever diverge. Consider declaring userStatus as v2.Status_ResourceStatus and assigning v2.Status_RESOURCE_STATUS_ENABLED / v2.Status_RESOURCE_STATUS_DISABLED in the switch, then passing it directly. Same applies at line 92 in agentResource.
Connector PR Review: Migrate off deprecated trait profile/status attributesBlocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review SummaryScanned the full PR diff (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.