Skip to content

Migrate off deprecated trait profile/status attributes - #13

Merged
laurenleach merged 1 commit into
mainfrom
lauren/migrate-deprecated-trait-attrs
Aug 7, 2026
Merged

Migrate off deprecated trait profile/status attributes#13
laurenleach merged 1 commit into
mainfrom
lauren/migrate-deprecated-trait-attrs

Conversation

@laurenleach

Copy link
Copy Markdown
Contributor

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.

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.
Comment thread pkg/connector/users.go
resource, err := rs.NewUserResource(user.Name, userResourceType, user.ID, userTraits)
resource, err := rs.NewUserResource(user.Name, userResourceType, user.ID, userTraits,
rs.WithResourceProfile(profile),
rs.WithResourceStatus(v2.Status_ResourceStatus(userStatus), ""))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: userStatus (line 36) is still typed as the deprecated trait enum v2.UserTrait_Status_Status and converted here. The values do line up 1:1 (UNSPECIFIED/ENABLED/DISABLED/DELETED = 0/1/2/3 in both enums), so this is correct today, but it's an unchecked cross-enum conversion that would silently produce the wrong status if the enums ever diverge. Declaring userStatus as v2.Status_ResourceStatus with v2.Status_RESOURCE_STATUS_DISABLED / ..._ENABLED drops both the cast and the last reference to the deprecated type.

Comment thread pkg/connector/roles.go
roleTraitOptions := []rs.RoleTraitOption{
rs.WithRoleProfile(profile),
}
roleTraitOptions := []rs.RoleTraitOption{}

@github-actions github-actions Bot Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: now that the profile option moved out, this empty slice literal only exists to fill the roleTraitOpts parameter. Passing nil directly (rs.NewRoleResource(role, roleResourceType, role, nil, rs.WithResourceProfile(profile))) is equivalent — WithRoleTrait() with no options still creates the role trait — and drops the variable entirely.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Connector PR Review: Migrate off deprecated trait profile/status attributes

Blocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 423be1cd60c7.
Review mode: full
View review run

Review Summary

Scanned the full PR diff (2 files, pkg/connector/roles.go and pkg/connector/users.go) for security and correctness. This is a pure SDK-API migration moving profile and status from the deprecated trait options onto the resource-level WithResourceProfile / WithResourceStatus options; verified against baton-sdk v0.22.0 (already pinned in go.mod, unchanged by this PR) that the new signatures match, that the resource options run before WithUserTrait/WithRoleTrait so the SDK trait-sync helpers do not clobber the explicitly-set values, and that UserTrait_Status_Status and Status_ResourceStatus are numerically identical (0/1/2/3), so the enum conversion is value-preserving. No remaining reads of the deprecated trait GetProfile()/GetStatus() exist anywhere in pkg/, so nothing in this connector breaks from the trait-level fields no longer being populated. Two non-blocking cleanups noted below.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • pkg/connector/users.go:36-49userStatus is still typed as the deprecated v2.UserTrait_Status_Status and numerically cast at the call site; declaring it as v2.Status_ResourceStatus removes the unchecked cross-enum conversion and the last deprecated-type reference.
  • pkg/connector/roles.go:55roleTraitOptions is now an empty slice literal that exists only to fill the parameter; passing nil is equivalent.
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In `pkg/connector/users.go`:
- Around line 36-49: userStatus is declared as v2.UserTrait_Status_Status (the
  deprecated trait enum) and then converted at the call site with
  v2.Status_ResourceStatus(userStatus). The two enums currently have identical
  values (UNSPECIFIED/ENABLED/DISABLED/DELETED = 0/1/2/3), so this is correct
  today, but the conversion is unchecked and would silently produce a wrong
  status if they ever diverge. Change the declaration to
  "var userStatus v2.Status_ResourceStatus", assign
  v2.Status_RESOURCE_STATUS_DISABLED when user.Locked is true and
  v2.Status_RESOURCE_STATUS_ENABLED otherwise, then pass userStatus directly to
  rs.WithResourceStatus(userStatus, "") with no cast.

In `pkg/connector/roles.go`:
- Around line 55-58: the roleTraitOptions variable is now an empty slice literal
  whose only purpose is to fill the roleTraitOpts parameter. Delete the variable
  and pass nil in its place:
  rs.NewRoleResource(role, roleResourceType, role, nil, rs.WithResourceProfile(profile)).
  WithRoleTrait() with no options still attaches the role trait, so behavior is
  unchanged.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

@laurenleach
laurenleach merged commit 37199bd into main Aug 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant