fix: migrate trait profile/status to resource-level APIs (SA1019) - #143
Conversation
Resolve golangci-lint SA1019 failures on main by using WithResourceProfile/WithResourceStatus and GetProfile/GetStatus instead of deprecated trait-level profile and status APIs. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Connector PR Review: fix: migrate trait profile/status to resource-level APIs (SA1019)Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryFull PR diff scanned for security and correctness. This is a clean deprecation migration moving profile/status off trait protos onto Resource via WithResourceProfile/WithResourceStatus, with reads going through GetProfile/GetStatus (resource-level first, trait fallback). Verified against the vendored SDK v0.20.2: the option and getter functions exist and behave as described, and the AgentTrait_AgentStatus to Status_ResourceStatus mapping is safe because both enums share identical numeric values (UNSPECIFIED=0, READY/ENABLED=1, DISABLED=2, DELETED=3). All trait-level profile/status readers were migrated (only pkg/bcel/bcel.go read them), status-detail handling is preserved, and no dependency, scope, or public-behavior changes are present. No new issues found. Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. |
Reading r.GetProfile() directly only resolves data written after the migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Reading r.GetProfile() directly only resolves data written after the migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Reading r.GetProfile() directly only resolves data written after the trait migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Reading r.GetProfile() directly only resolves data written after the trait migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Follow-up to the trait profile/status migration. That migration moved reads from the deprecated trait fields to the resource itself (`r.GetProfile()`). That is correct for data written by a connector which has already migrated, but it returns nothing for data synced **before** the migration, where the profile still lives on the trait annotation. baton-sdk provides compatibility getters for exactly this (`pkg/types/resource/resource_attrs.go`): `GetProfile`, `GetStatus`, `GetCreatedAt`, and `GetIcon` read the resource-level attribute first and fall back to the deprecated trait field. This switches the reads to those helpers so previously-synced data still resolves. Reads only — the write side (`WithResourceProfile` / `WithResourceStatus`) is unchanged. Reference: ConductorOne/baton-sql#143. `golangci-lint run ./...` reports 0 issues and the package tests pass.
Reading r.GetProfile() directly only resolves data written after the trait migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Reading r.GetProfile() directly only resolves data written after the trait migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Reading r.GetProfile() directly only resolves data written after the trait migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
Reading r.GetProfile() directly only resolves data written after the trait migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level attribute first and fall back to the deprecated trait field, so previously-synced data still resolves. Reads only; the write side is unchanged. Reference: ConductorOne/baton-sql#143.
* Migrate off deprecated trait profile/status attributes
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.
* Use baton-sdk resource attribute helpers for profile/status reads
Reading r.GetProfile() directly only resolves data written after the trait
migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level
attribute first and fall back to the deprecated trait field, so previously-synced
data still resolves. Reads only; the write side is unchanged.
Reference: ConductorOne/baton-sql#143.
* Migrate off deprecated trait profile/status attributes
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` -> `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. Login and
login-alias data stays on `UserTrait` and 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.
* Use baton-sdk resource attribute helpers for profile/status reads
Reading r.GetProfile() directly only resolves data written after the trait
migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level
attribute first and fall back to the deprecated trait field, so previously-synced
data still resolves. Reads only; the write side is unchanged.
Reference: ConductorOne/baton-sql#143.
Follow-up to the trait profile/status migration. That migration moved reads from the deprecated trait fields to the resource itself (`r.GetProfile()`). That is correct for data written by a connector which has already migrated, but it returns nothing for data synced **before** the migration, where the profile still lives on the trait annotation. baton-sdk provides compatibility getters for exactly this (`pkg/types/resource/resource_attrs.go`): `GetProfile`, `GetStatus`, `GetCreatedAt`, and `GetIcon` read the resource-level attribute first and fall back to the deprecated trait field. This switches the reads to those helpers so previously-synced data still resolves. Reads only — the write side (`WithResourceProfile` / `WithResourceStatus`) is unchanged. Reference: ConductorOne/baton-sql#143. `golangci-lint run ./...` reports 0 issues and the package tests pass.
* Migrate off deprecated trait profile/status attributes
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.
* Use baton-sdk resource attribute helpers for profile/status reads
Reading r.GetProfile() directly only resolves data written after the trait
migration. baton-sdk's resource.GetProfile / GetStatus read the resource-level
attribute first and fall back to the deprecated trait field, so previously-synced
data still resolves. Reads only; the write side is unchanged.
Reference: ConductorOne/baton-sql#143.
Follow-up to the trait profile/status migration. That migration moved reads from the deprecated trait fields to the resource itself (`r.GetProfile()`). That is correct for data written by a connector which has already migrated, but it returns nothing for data synced **before** the migration, where the profile still lives on the trait annotation. baton-sdk provides compatibility getters for exactly this (`pkg/types/resource/resource_attrs.go`): `GetProfile`, `GetStatus`, `GetCreatedAt`, and `GetIcon` read the resource-level attribute first and fall back to the deprecated trait field. This switches the reads to those helpers so previously-synced data still resolves. Reads only — the write side (`WithResourceProfile` / `WithResourceStatus`) is unchanged. Reference: ConductorOne/baton-sql#143. `golangci-lint run ./...` reports 0 issues and the package tests pass.
Summary
Fixes Verify workflow golangci-lint SA1019 failures on
main(18 staticcheck issues) after baton-sdk deprecations moved profile/status off trait protos ontoResource.Changes
pkg/bcel/bcel.go: CELresource.profilenow usessdkResource.GetProfile(resource-level with trait fallback) instead of deprecatedGet*Trait(...).GetProfile().pkg/bsql/resources.go:WithResourceProfileWithResourceStatus(Status_ResourceStatus; agent READY maps to ENABLED)pkg/bsql/nhi_test.go: assertions updated to resource-level status/profileNon-goals
Test plan
golangci-lintv2.11.4 (CI version): 0 issuesgo test ./...green