Skip to content

[CXH-2015] - Return InvalidArgument instead of panicking on empty resource_id in enable_user/disable_user#37

Merged
sergiocorral-conductorone merged 1 commit into
mainfrom
sergiocorral/cxh-2015-baton-retool-empty-resource_id-in-enable_userdisable_user
Jul 14, 2026
Merged

[CXH-2015] - Return InvalidArgument instead of panicking on empty resource_id in enable_user/disable_user#37
sergiocorral-conductorone merged 1 commit into
mainfrom
sergiocorral/cxh-2015-baton-retool-empty-resource_id-in-enable_userdisable_user

Conversation

@sergiocorral-conductorone

Copy link
Copy Markdown
Contributor

Summary

Fixes CXH-2015

The enable_user/disable_user global actions validated the user_id argument's resource type but not its resource ID. An empty resource_id reached parseObjectID, which performs id[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 clean InvalidArgument status.

Changes

  • pkg/connector/helpers.go: Added a len(id) < 2 guard in parseObjectID that returns fmt.Errorf("invalid resource id: %q", id) instead of panicking. The existing error-handling in setUserActive already converts this into an InvalidArgument gRPC status — no change to actions.go was needed.
  • pkg/connector/helpers_test.go: New test file covering parseObjectID with empty string, single-char string, valid ID, and invalid format — all four cases pass without panicking.

Repro Steps

  1. Configure the connector with a valid Retool instance.
  2. Trigger the enable_user or disable_user action with a user_id argument whose resource_id field is empty.
  3. Before fix: action fails with a raw panic string (slice bounds out of range [1:0]).
  4. After fix: action returns a clean InvalidArgument status with the message baton-retool: invalid user_id "": invalid resource id: "".

🤖 Generated with Claude Code

… 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>
@sergiocorral-conductorone
sergiocorral-conductorone requested a review from a team July 10, 2026 17:13
@linear-code

linear-code Bot commented Jul 10, 2026

Copy link
Copy Markdown

CXH-2015

@github-actions

Copy link
Copy Markdown

Connector PR Review: [CXH-2015] - Return InvalidArgument instead of panicking on empty resource_id in enable_user/disable_user

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

Review Summary

The full PR diff was scanned for security and correctness. The change adds a len(id) < 2 guard to parseObjectID (pkg/connector/helpers.go), preventing a slice-bounds-out-of-range panic on empty or single-character resource IDs; the existing caller in setUserActive already maps the returned error to a gRPC InvalidArgument status (pkg/connector/actions.go:121-124), so no change to actions.go was needed. The fix is correctly scoped and does not regress valid IDs (a type prefix plus digits, length >= 2) used by the other parseObjectID callers during sync, and it is covered by a new table-driven test. No new issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No blocking issues found.

Comment thread pkg/connector/helpers.go
@btipling btipling removed their assignment Jul 13, 2026
@sergiocorral-conductorone
sergiocorral-conductorone merged commit d6657df into main Jul 14, 2026
5 checks passed
@sergiocorral-conductorone
sergiocorral-conductorone deleted the sergiocorral/cxh-2015-baton-retool-empty-resource_id-in-enable_userdisable_user branch July 14, 2026 15:37
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.

6 participants