[CXH-2015] - Return InvalidArgument instead of panicking on empty resource_id in enable_user/disable_user#37
Conversation
… in enable_user/disable_user (CXH-2015) An empty or too-short resource_id passed to parseObjectID caused a slice-bounds panic; now returns a clean error surfaced as InvalidArgument. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Connector PR Review: [CXH-2015] - Return InvalidArgument instead of panicking on empty resource_id in enable_user/disable_userBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryThe full PR diff was scanned for security and correctness. The change adds a Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. |
Summary
Fixes CXH-2015
The
enable_user/disable_userglobal actions validated theuser_idargument's resource type but not its resource ID. An emptyresource_idreachedparseObjectID, which performsid[1:]with no length check, causing a slice-bounds-out-of-range panic. The SDK's action framework recovers the panic, but the action failed with a raw panic string instead of a cleanInvalidArgumentstatus.Changes
pkg/connector/helpers.go: Added alen(id) < 2guard inparseObjectIDthat returnsfmt.Errorf("invalid resource id: %q", id)instead of panicking. The existing error-handling insetUserActivealready converts this into anInvalidArgumentgRPC status — no change toactions.gowas needed.pkg/connector/helpers_test.go: New test file coveringparseObjectIDwith empty string, single-char string, valid ID, and invalid format — all four cases pass without panicking.Repro Steps
enable_userordisable_useraction with auser_idargument whoseresource_idfield is empty.slice bounds out of range [1:0]).InvalidArgumentstatus with the messagebaton-retool: invalid user_id "": invalid resource id: "".🤖 Generated with Claude Code