Skip to content

Conversation

@LeMyst
Copy link
Owner

@LeMyst LeMyst commented Nov 10, 2025

Updated the construction of the 'User-Agent' header in both Login and Clientlogin classes to use a fallback to config['USER_AGENT'] if user_agent is not provided, ensuring a valid user agent string is always set.

Updated the construction of the 'User-Agent' header in both Login and Clientlogin classes to use a fallback to config['USER_AGENT'] if user_agent is not provided, ensuring a valid user agent string is always set.
Copilot AI review requested due to automatic review settings November 10, 2025 12:32
Copy link
Contributor

Copilot AI left a comment

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 the User-Agent header handling in the Login and Clientlogin classes to add fallback logic that uses the global config's USER_AGENT value when no explicit user agent is provided. However, the implementation introduces code duplication.

  • The fallback logic user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None) is applied twice in each class
  • The duplication occurs both where the variable is first assigned and again when passed to get_user_agent()


headers = {
'User-Agent': get_user_agent(user_agent)
'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None))
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The fallback logic user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None) is redundant here. The variable user_agent was already resolved with the same fallback logic on line 215, so this line can be simplified to just get_user_agent(user_agent).

Suggested change
'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None))
'User-Agent': get_user_agent(user_agent)

Copilot uses AI. Check for mistakes.

headers = {
'User-Agent': get_user_agent(user_agent)
'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None))
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The fallback logic user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None) is redundant here. The variable user_agent was already resolved with the same fallback logic on line 274, so this line can be simplified to just get_user_agent(user_agent).

Suggested change
'User-Agent': get_user_agent(user_agent or (str(config['USER_AGENT']) if config['USER_AGENT'] is not None else None))
'User-Agent': get_user_agent(user_agent)

Copilot uses AI. Check for mistakes.
@LeMyst LeMyst closed this Nov 10, 2025
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