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.
| rs.WithResourceProfile(profile), | ||
| rs.WithResourceStatus(v2.Status_RESOURCE_STATUS_ENABLED, ""), | ||
| rs.WithParentResourceID(parentResourceID), | ||
| rs.WithExternalID(&v2.ExternalId{Id: user.ID}), |
There was a problem hiding this comment.
🟡 Suggestion: rs.WithExternalID is also deprecated in this SDK version (resource.go: "Deprecated. This field is no longer used.") and nothing in this connector reads GetExternalId() — Grant/Revoke here use principal.Id.Resource / grant.Principal.Id.Resource. staticcheck doesn't flag it only because the SDK's comment isn't in the Deprecated: paragraph form, so it slipped past the SA1019 sweep. Consider dropping it in this same cleanup.
| } | ||
|
|
||
| groupId, ok := rs.GetProfileStringValue(groupTrait.Profile, "group_id") | ||
| groupId, ok := rs.GetProfileStringValue(rs.GetProfile(resource), "group_id") |
There was a problem hiding this comment.
🟡 Suggestion: Grants now depends on the profile round-tripping through the resource-level field rather than the group trait, and there is no test covering it (license_test.go only asserts LicenseProfileTrait). A small test that builds groupResource(...) and asserts rs.GetProfileStringValue(rs.GetProfile(res), "group_id") returns the ID would lock in this migration and guard the grant path.
There was a problem hiding this comment.
GetProfile will fall back to group trait if resource profile is not set
Connector PR Review: Migrate off deprecated trait profile/status attributesBlocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0 Review SummaryScanned the full PR diff (3 files, 7 additions / 12 deletions) for security and correctness. The migration is faithful to baton-sdk v0.22.0: 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.