fix(secure): use protojson serializer for organization updates#724
fix(secure): use protojson serializer for organization updates#724tembleking merged 2 commits intomasterfrom
Conversation
UpdateOrganizationSecure was using json.Marshal which produces snake_case field names (management_account_id, organization_root_id), while the cloudauth backend expects protobuf JSON with camelCase fields (managementAccountId, organizationRootId). This caused the API to return 500 on every update attempt, making organization updates impossible. The create path already used the correct marshalCloudauthProto serializer.
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the UpdateOrganizationSecure method where it was incorrectly using the standard JSON serializer (json.Marshal) instead of the protobuf JSON serializer (protojson.Marshal). This caused API requests to be sent with snake_case field names (management_account_id, organization_root_id) instead of the camelCase field names (managementAccountId, organizationRootId) that the cloudauth backend expects, resulting in 500 errors on all organization update attempts. The fix aligns the update path with the already-correct create path.
Changes:
- Fixed
UpdateOrganizationSecureto usec.marshalCloudauthProto()instead ofMarshal() - Added comprehensive test
TestUpdateOrganizationSecureUsesCamelCasethat verifies the request body uses camelCase field names
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sysdig/internal/client/v2/organization.go | Changed marshal serializer in UpdateOrganizationSecure from standard JSON to protobuf JSON |
| sysdig/internal/client/v2/organization_test.go | Added test to verify UpdateOrganizationSecure uses camelCase field names in request payload |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
UpdateOrganizationSecurewas usingjson.Marshal(standard Go JSON) which produces snake_case field names (management_account_id,organization_root_id), while the cloudauth backend expects protobuf JSON with camelCase fields (managementAccountId,organizationRootId). This caused the API to return 500 on every update attempt, making organization updates impossible.The create path already used the correct
marshalCloudauthProtoserializer. This aligns the update path to use the same one.