Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Sep 20, 2025

Fix TraceBatchManager authentication handling for issue #3559

Summary

Fixes a critical backward compatibility issue where crews would crash with an AuthError when no authentication token is present. The root cause was that get_auth_token() was called outside the existing try-catch block in TraceBatchManager.__init__(), causing the exception to bubble up and crash crew initialization.

Key change: Moved the get_auth_token() call inside the existing try-catch block so that when authentication fails, the system gracefully falls back to using an empty API key for ephemeral batch operation.

This restores the expected behavior where crews can run without authentication by using ephemeral traces instead of crashing during initialization.

Review & Testing Checklist for Human

🔴 High Priority - 4 critical items to verify:

  • End-to-end verification: Create and run a crew without any authentication token set - it should work without crashing
  • Authenticated scenario: Verify that crews with valid authentication tokens still work correctly and create backend batches
  • Ephemeral batch functionality: Test that TraceBatchManager with empty API key successfully creates ephemeral batches and handles 401 responses gracefully
  • PlusAPI behavior: Verify that PlusAPI(api_key="") doesn't cause downstream issues or unexpected behavior in tracing operations

Notes

  • All tests pass including the new test coverage for missing authentication scenarios
  • The fix is minimal (2-line change) but in a critical code path that affects all crew executions
  • Added comprehensive test coverage including both unit tests and standalone verification script
  • Original issue reported that "recent changes broke previously running crews" - this should restore that functionality

Link to Devin session: https://app.devin.ai/sessions/cee3d4ea212a4651884b1c66686ef9d4
Requested by: João ([email protected]) via Slack

- Move get_auth_token() call inside try-catch block in TraceBatchManager.__init__
- This allows graceful handling of AuthError when no authentication token is present
- Crews can now work without authentication by using ephemeral batches
- Add test to verify TraceBatchManager handles missing auth gracefully
- Add standalone test script that confirms the fix works correctly

Fixes issue where recent changes broke previously running crews due to
mandatory authentication in the tracing system.

Co-Authored-By: João <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

cursor[bot]

This comment was marked as outdated.

- Use crew variable to avoid F841 unused variable error
- Remove API key logging to address CodeQL security alert
- Make path portable using os.path.join

Co-Authored-By: João <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

Closing due to inactivity for more than 7 days. Configure here.

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