Skip to content

Conversation

icecrasher321
Copy link
Collaborator

Summary

Google Drive: Effect kept retrying on 401 because it didn't clear the selection → Fixed by clearing selection and showing OAuth modal on 401.

Slack: Effect kept retrying on error because initialFetchDone was never set to true on failures → Fixed by always setting initialFetchDone = true regardless of success/failure.

Type of Change

  • Bug fix

Testing

Manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 18, 2025 6:26pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 18, 2025 6:26pm

@vercel vercel bot temporarily deployed to Preview – docs September 18, 2025 18:22 Inactive
@icecrasher321 icecrasher321 merged commit 3905d1c into staging Sep 18, 2025
6 checks passed
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This pull request fixes critical infinite loop bugs in two selector components - the Google Drive picker and Slack channel selector. Both components were experiencing continuous retry loops when encountering error conditions.

For the Google Drive picker, the fix addresses two scenarios that caused infinite retries:

  1. Invalid credential persistence: When a previously stored credentialId was no longer valid (deleted/revoked), the component would continuously attempt to use it. The fix adds validation to clear the selectedCredentialId when it's not found in the fetched credentials list.
  2. 401 authentication errors: When API calls returned 401 (unauthorized), the component would keep retrying the same failed request without prompting re-authentication. The fix handles 401 responses by clearing the selection (setSelectedFileId(''), onChange(''), onFileInfoChange?.(null)) and showing the OAuth modal (setShowOAuthModal(true)).

For the Slack channel selector, the issue was in the error handling flow where initialFetchDone was only set to true on successful responses, never on failures. This caused the useEffect hook to continuously trigger fetchChannels() because the condition !initialFetchDone remained true for failed requests. The fix ensures initialFetchDone = true is set in all error paths:

  • HTTP errors (non-ok responses)
  • API error responses (when data.error exists)
  • Exception handling in the catch block

These changes align with the existing error handling patterns in the codebase and provide proper user feedback pathways for authentication and error scenarios. The fixes prevent resource waste from continuous API retries and improve user experience by offering clear recovery paths.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it fixes clear bugs without introducing new functionality
  • Score reflects well-targeted bug fixes that address specific infinite loop scenarios with proper error handling
  • No files require special attention as the changes are straightforward error handling improvements

2 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment on lines +103 to +105
if (credentialId && !data.credentials.some((c: any) => c.id === credentialId)) {
setSelectedCredentialId('')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Type assertion to any should be avoided. Consider defining a proper type for the credential object.

Suggested change
if (credentialId && !data.credentials.some((c: any) => c.id === credentialId)) {
setSelectedCredentialId('')
}
if (credentialId && !data.credentials.some((c: Credential) => c.id === credentialId)) {
setSelectedCredentialId('')
}

Context Used: Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)

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.

1 participant