Skip to content

fix(debug): fixes issue with debug showing incorrect info#253

Merged
binoy14 merged 2 commits intomainfrom
01-06-fix_debug_fixes_issue_with_debug_showing_incorrect_info
Jan 14, 2026
Merged

fix(debug): fixes issue with debug showing incorrect info#253
binoy14 merged 2 commits intomainfrom
01-06-fix_debug_fixes_issue_with_debug_showing_incorrect_info

Conversation

@binoy14
Copy link
Contributor

@binoy14 binoy14 commented Jan 6, 2026

Fixes the debug command to match the current CLI. There is some history and subtle difference in the me endpoint when using on the project domain vs global. The global user ID does not match the project role member id so we are using the projects domain whenever possible.

@claude
Copy link

claude bot commented Jan 6, 2026

Claude finished @binoy14's task —— View job


Code Review Complete

  • Read repository guidelines (CLAUDE.md)
  • Analyze changed files for issues
  • Review test coverage and quality
  • Provide actionable feedback

Issues Found

Missing Error Handling for API Failures

The gatherProjectInfo function on line 127 in gatherDebugInfo.ts uses unsafe member access that could throw if the API response has unexpected structure:

const member = (projectInfo.members || []).find((member) => member.id === userId)

Fix: Add null check for member.id before comparison since members might have incomplete data.

Type Safety Issue

Line 132 in gatherDebugInfo.ts has a @ts-expect-error comment that suppresses legitimate type errors:

// @ts-expect-error - Incorrect type definition in @sanity/client
userRoles: member && member.roles ? member.roles.map((role) => role.name) : ['<none>'],

Fix: Either update the @sanity/client types or add proper type guards instead of suppressing errors.

Inconsistent Return Types

The gatherUserInfo function returns Error | UserInfo | null but the logic flow can be confusing. Line 91-93 uses a conditional that could be clearer about when project vs global user lookup occurs.
Fix: Add inline comment explaining the conditional logic for project vs global user lookup.

Test Coverage Gap

The test file doesn't cover the edge case where getProjectUser fails but getCliUser would succeed as a fallback. This could mask issues with the project user endpoint.
Fix: Add test case covering project user API failure with global user fallback.

Minor Issues

Performance: Multiple sequential API calls could be parallelized better in gatherDebugInfo.ts:26-28, though this is a minor optimization.

Code Style: The user service function getProjectUser on line 34 in user.ts lacks JSDoc description of its return type behavior compared to getCliUser.

All major functionality changes look correct and the fix addresses the stated issue with global vs project domain user ID differences.

Copy link
Contributor Author

binoy14 commented Jan 6, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 76.65% 5370 / 7005
🔵 Statements 75.8% 5502 / 7258
🔵 Functions 67.2% 795 / 1183
🔵 Branches 63.78% 2376 / 3725
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/cli/src/actions/debug/gatherDebugInfo.ts 92.3% 83.33% 100% 92.1% 65, 73, 116
packages/@sanity/cli/src/commands/debug.ts 100% 87.5% 100% 100%
packages/@sanity/cli/src/services/user.ts 100% 100% 100% 100%
Generated in workflow #1415 for commit faedaa2 by the Vitest Coverage Report Action

@binoy14 binoy14 force-pushed the 01-06-fix_debug_fixes_issue_with_debug_showing_incorrect_info branch from c0d6563 to ee6b967 Compare January 6, 2026 18:09
@binoy14 binoy14 marked this pull request as ready for review January 6, 2026 18:14
@binoy14 binoy14 requested a review from a team as a code owner January 6, 2026 18:14
@binoy14 binoy14 requested review from colepeters and mttdnt and removed request for a team January 6, 2026 18:14
@binoy14 binoy14 force-pushed the 01-06-fix_debug_fixes_issue_with_debug_showing_incorrect_info branch 2 times, most recently from 8e32b4b to c0575b3 Compare January 8, 2026 02:44
@binoy14 binoy14 force-pushed the 01-06-fix_debug_fixes_issue_with_debug_showing_incorrect_info branch from c0575b3 to faedaa2 Compare January 9, 2026 17:43
@binoy14 binoy14 merged commit 0592afd into main Jan 14, 2026
22 checks passed
@binoy14 binoy14 deleted the 01-06-fix_debug_fixes_issue_with_debug_showing_incorrect_info branch January 14, 2026 19:12
@squiggler-legacy squiggler-legacy bot mentioned this pull request Jan 14, 2026
@squiggler-app squiggler-app bot mentioned this pull request Mar 11, 2026
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.

2 participants