Skip to content

Conversation

@Takahiro-Yoko
Copy link

@Takahiro-Yoko Takahiro-Yoko commented Dec 15, 2024

fixes #1446
maybe also fixes #1445
maybe also fixes #1451
maybe also fixes #1458 (I'm not sure which is better, remove Depends() or Request type hint)
maybe also fixes #1459
maybe also fixes #1460

Description

#1426 added request (type Request) argument to get_current_user function, but not importing fastapi.Request. This causes below error.
superagi_error_20241214_114222
I've added from fastapi import Request in superagi/helper/auth.py (97f108f), and this solves above error, but causes another issue. Seems like relating to fastapi/fastapi#9897
superagi_error_20241215_095538
So, I've simply removed Request type hint from get_current_user. Maybe better solution exists, but for now, this works fine.

Related Issues

#1426
fastapi/fastapi#9897

Solution and Design

Removed Request type hint from get_current_user

Test Plan

Run docker compose -f docker-compose.yaml up backend
Confirm Application startup complete. message showing up.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Docs update

Checklist

  • My pull request is atomic and focuses on a single change.
  • I have read the contributing guide and my code conforms to the guidelines.
  • I have documented my changes clearly and comprehensively.
  • I have added the required tests.

@maveric
Copy link

maveric commented Feb 9, 2025

This fix worked for me on windows as of 2025-2-9. Was stuck on the first loading screen when loading http://localhost:3000

@vineetshar
Copy link

Had the same problem on macOS , can confirm this PR fixes it.

@hidde-s
Copy link

hidde-s commented May 29, 2025

Can confirm this fixed being stuck on the initializing SuperAGI screen on windows 11 for me.

@Takahiro-Yoko Takahiro-Yoko changed the title Fix minor bug introduced in 1426 Fix bug (stucking on "Initializing SuperAGI...") introduced in #1426 Jun 1, 2025
@notnizar
Copy link

notnizar commented Jul 7, 2025

change the get_current_user to this

def get_current_user(Authorize: AuthJWT = Depends(check_auth)):
env = get_config("ENV", "DEV")

if env == "DEV":
    email = "[email protected]"
else:
    # Retrieve the email of the logged-in user from the JWT token payload
    email = Authorize.get_jwt_subject()

# Query the User table to find the user by their email
user = db.session.query(User).filter(User.email == email).first()
return user

@Takahiro-Yoko
Copy link
Author

Thank you for confirming!

Thank you for your comment. I'm not sure why but this PR updated get_current_user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment