Move duplicate trait attributes to resource.#996
Conversation
| # Trait tests intentionally exercise deprecated trait fields for backwards compatibility. | ||
| - linters: | ||
| - staticcheck | ||
| path: pkg/types/resource/.*_test\.go | ||
| text: "SA1019" |
There was a problem hiding this comment.
🟠 Bug: Deprecating these trait proto fields (profile/icon/status/created_at) makes staticcheck SA1019 fire on every non-test caller that reads or writes them. This SA1019 exclusion only covers pkg/types/resource/*_test.go, but there are unguarded production callers — pkg/c1zsanitize/handlers.go (reads via getters and writes via UserTrait_builder{Profile,Icon}/SetStatus/SetCreatedAt), pkg/sync/syncer.go:1382,1391,1400,2361,2374, and pkg/baton/explorer/baton_service.go:23-24. make lint (staticcheck is enabled) will fail. Either broaden this exclusion / add //nolint:staticcheck at those sites, or migrate those callers to the resource-level fields. (confidence: high)
578cdcf to
8ec25c9
Compare
| string nhi_detail = 2 [(validate.rules).string = { | ||
| ignore_empty: true | ||
| max_bytes: 1024 | ||
| min_bytes: 1 | ||
| }]; |
There was a problem hiding this comment.
🟡 Suggestion: This adds a new min_bytes:1/max_bytes:1024 constraint to nhi_detail (a validation tightening) that's unrelated to the PR's stated purpose of moving trait attributes to the resource. ignore_empty keeps empty values valid, but any connector currently emitting an nhi_detail longer than 1024 bytes would newly fail validation. Confirm this tightening is intended and safe for existing callers. (confidence: low)
| string nhi_detail = 2 [(validate.rules).string = { | ||
| ignore_empty: true | ||
| max_bytes: 1024 | ||
| min_bytes: 1 | ||
| }]; |
There was a problem hiding this comment.
🟡 Suggestion: This tightens nhi_detail validation (new max_bytes: 1024) where none existed before. It's intentional per the PR description, but any existing connector emitting a longer detail will now fail message validation at sync time — worth confirming no downstream connector relies on longer values before this ships. (confidence: medium)
General PR Review: Move duplicate trait attributes to resource.Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review SummaryFull PR diff scanned for security and correctness. This PR adds resource-level Two items from prior reviews still apply and are not re-flagged inline: Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
8ec25c9 to
7143eb3
Compare
7143eb3 to
ca995ec
Compare
|
|
||
| message Status { | ||
| enum ResourceStatus { | ||
| RESOURCE_STATUS_STATUS_UNSPECIFIED = 0; |
There was a problem hiding this comment.
🟡 Suggestion: The zero value RESOURCE_STATUS_STATUS_UNSPECIFIED has a doubled STATUS_STATUS segment; every other zero value in this codebase follows <PREFIX>_UNSPECIFIED (e.g. AGENT_STATUS_UNSPECIFIED). Since this is a brand-new wire enum, the name is free to fix now but permanent once shipped — consider RESOURCE_STATUS_UNSPECIFIED. (medium confidence)
Add WithResourceProfile, WithResourceIcon, and WithResourceStatus to ResourceOption. Deprecate old trait options, but have them still work by syncing the trait attributes to the resource. Protofmt.
ca995ec to
a461893
Compare
| # Tests intentionally exercise deprecated fields (e.g. trait-level | ||
| # profile/icon/status/created_at) to cover backwards compatibility with | ||
| # data written by older connectors. | ||
| - linters: | ||
| - staticcheck | ||
| path: _test\.go | ||
| text: "SA1019" |
There was a problem hiding this comment.
🟡 Suggestion: This blanket SA1019 exclusion suppresses all staticcheck deprecation warnings across every _test.go file, not just the trait-level profile/icon/status/created_at fields it's intended for. It could mask unrelated future deprecations in tests. Consider narrowing the text: to the specific deprecated symbols (as the existing dotc1z.NewC1ZFile rule above does) to keep coverage tight. (confidence: medium, non-blocking)
Add WithResourceProfile, WithResourceIcon, and WithResourceStatus to ResourceOption.
Deprecate old trait options, but have them still work by syncing the trait attributes to the resource.
Limit NHI details to 1024 bytes.
Protofmt.