Skip to content

chore: handle django_q not present in requirements - #61

Merged
Hrishabh17 merged 1 commit into
masterfrom
django_q_import_fix
Aug 5, 2026
Merged

chore: handle django_q not present in requirements#61
Hrishabh17 merged 1 commit into
masterfrom
django_q_import_fix

Conversation

@Hrishabh17

Copy link
Copy Markdown
Member

No description provided.

Copilot AI lite review requested due to automatic review settings August 5, 2026 12:28

Copilot AI 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.

Pull request overview

This PR updates fyle-rest-auth to avoid importing django_q at module import time by switching to runtime loading of django_q.tasks.async_task, and bumps the package version accordingly.

Changes:

  • Bumped package version from 1.8.4 to 1.8.5.
  • Removed top-level django_q import and switched to import_string('django_q.tasks.async_task') at call sites for async updates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
setup.py Bumps the package version to 1.8.5.
fyle_rest_auth/helpers.py Replaces eager django_q import with runtime loading of async_task for optional async credential updates.
Suppressed comments (3)

fyle_rest_auth/helpers.py:86

  • If django_q isn’t installed, import_string('django_q.tasks.async_task') raises ImportError and the whole login flow fails (caught by the outer except Exception and re-raised as ValidationError). Since the PR goal is to tolerate django_q being absent, guard this import and fall back to the synchronous task (or skip) instead of failing authentication.

This issue also appears in the following locations of the same file:

  • line 145
  • line 157
        if 'async_update_user' in settings.FYLE_REST_AUTH_SETTINGS:
            if settings.FYLE_REST_AUTH_SETTINGS['async_update_user']:
                async_task = import_string('django_q.tasks.async_task')
                async_task(
                    'apps.workspaces.tasks.async_update_fyle_credentials',
                    employee_info['data']['org']['id'], tokens['refresh_token']
                )

fyle_rest_auth/helpers.py:163

  • async_update_user_settings_api currently hard-requires django_q; if it’s missing, import_string('django_q.tasks.async_task') will abort the whole request. Since this block is an optional background update, catch ImportError and log + skip (or provide a non-django_q fallback).
        if 'async_update_user_settings_api' in settings.FYLE_REST_AUTH_SETTINGS \
            and settings.FYLE_REST_AUTH_SETTINGS['async_update_user_settings_api']:
            async_task = import_string('django_q.tasks.async_task')
            async_task(
                'apps.orgs.tasks.async_update_fyle_credentials',
                employee_info['data']['org']['id'], tokens['refresh_token']
            )

fyle_rest_auth/helpers.py:151

  • Same issue here: when async_update_user is enabled but django_q isn’t installed, this ImportError causes refresh-token login to fail even though the async update is optional. Guard the import and fall back to the synchronous update instead of raising ValidationError.
        if 'async_update_user' in settings.FYLE_REST_AUTH_SETTINGS:
            if settings.FYLE_REST_AUTH_SETTINGS['async_update_user']:
                async_task = import_string('django_q.tasks.async_task')
                async_task(
                    'apps.workspaces.tasks.async_update_fyle_credentials',
                    employee_info['data']['org']['id'], tokens['refresh_token']
                )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Hrishabh17
Hrishabh17 merged commit 1f3b3c1 into master Aug 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants