Skip to content

Fix variable name mismatch in weather service logging configuration#3

Merged
Hsail merged 2 commits intomainfrom
copilot/fix-1-2
May 20, 2025
Merged

Fix variable name mismatch in weather service logging configuration#3
Hsail merged 2 commits intomainfrom
copilot/fix-1-2

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2025

Bug Description

The weather service was failing to start when a --log-level parameter was provided, raising a NameError exception due to a variable name mismatch in the server code.

What Changed

Fixed a variable name inconsistency in the server.py file:

  • The command line parameter and function parameter is named log_level
  • But it was being referenced as loglevel (without the underscore) in the logging configuration
  • Changed loglevel.upper() to log_level.upper() to ensure consistency

Before the Fix

When running the command:

mcp-get-weather --port 3000 --api-key <API_KEY> --log-level INFO

The program would fail with:

NameError: name 'loglevel' is not defined. Did you mean: 'log_level'?

After the Fix

The program now starts successfully and configures logging with the specified level.

Fixes #1.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Hsail <25000162+Hsail@users.noreply.github.com>
Copilot AI changed the title [WIP] Bug: 程序在运行 mcp-get-weather 命令时抛出异常并终止执行 Fix variable name mismatch in weather service logging configuration May 20, 2025
Copilot AI requested a review from Hsail May 20, 2025 17:01
Copilot finished work on behalf of Hsail May 20, 2025 17:01
@Hsail
Copy link
Copy Markdown
Owner

Hsail commented May 20, 2025

@github-copilot[bot] 请检查此 PR 是否符合代码规范,并运行所有相关测试。

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 20, 2025

@github-copilot[bot] 请检查此 PR 是否符合代码规范,并运行所有相关测试。

I've reviewed the PR changes and verified they adhere to the code standards. The fix is minimal and correct, changing loglevel.upper() to log_level.upper() to match the parameter name used in the function signature.

I ran code quality checks with flake8 and black. While there are some minor style issues in the codebase (unused imports, missing newlines), none are related to our fix. The installation process works, and the CLI can be successfully executed.

There are no specific tests in the repository for this functionality, but manual verification confirms the fix resolves the NameError exception when using the --log-level parameter.

Commit: 9406f05

Copilot finished work on behalf of Hsail May 20, 2025 17:06
@Hsail Hsail marked this pull request as ready for review May 20, 2025 17:06
@Hsail Hsail merged commit a119036 into main May 20, 2025
1 check passed
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.

Bug: 程序在运行 mcp-get-weather 命令时抛出异常并终止执行

2 participants