Skip to content

Conversation

@KushagraaWadhwa
Copy link

@KushagraaWadhwa KushagraaWadhwa commented Nov 11, 2025

Enhance --sysinfo to include version and masked environment variables

🎯 Description

This PR enhances the --sysinfo option to provide more comprehensive debugging information by adding version tracking and environment variable visibility while maintaining security through sensitive data masking.

Addresses the feature request for improved system information output to help diagnose issues more effectively.

✨ Changes

New Functions Added

  1. get_gpt_engineer_version()

    • Detects the exact version of gpt-engineer
    • Identifies installation type (released from pip vs development from GitHub repo)
    • Handles edge cases like .dev, .post, and git hash suffixes
  2. get_environment_variables()

    • Captures relevant environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY, MODEL_NAME, etc.)
    • Supports wildcard patterns (e.g., GPT_ENGINEER_*)
    • Indicates which variables are set vs "not set"
  3. mask_sensitive_value()

    • Automatically masks API keys, secrets, tokens, passwords, and credentials
    • Shows first 4 and last 4 characters for long values (e.g., sk-p...cdef (length: 24))
    • Shows ****** (length: X) for shorter sensitive values
    • Non-sensitive values displayed in full

Enhanced Features

  • Improved output formatting with clear separators and nested dictionary support
  • Updated get_system_info() to include version and environment information
  • Better readability with structured display

🧪 Testing

  • ✅ Added comprehensive unit tests in tests/applications/cli/test_sysinfo.py
  • ✅ Tests cover all new functions with multiple scenarios
  • ✅ No linting errors introduced
  • ✅ All functions have proper docstrings following NumPy style

📊 Example Output

Before:

os: Darwin
os_version: Darwin Kernel Version 23.0.0
architecture: arm64
python_version: 3.11.0...
packages: openai: 1.0.0
typer: 0.9.0
...

After:

============================================================
System Information
============================================================
os: Darwin
os_version: Darwin Kernel Version 23.0.0
architecture: arm64
python_version: 3.11.0...

gpt_engineer_version:
  version: 0.3.1
  install_type: development (from GitHub repo)

environment_variables:
  OPENAI_API_KEY: sk-p...xyz7 (length: 51)
  ANTHROPIC_API_KEY: not set
  AZURE_OPENAI_API_KEY: not set
  MODEL_NAME: gpt-4
  OPENAI_BASE_URL: not set
  LOCAL_MODEL: not set

packages: openai: 1.0.0
typer: 0.9.0
...
============================================================

🎁 Benefits

  1. Version Tracking

    • Helps diagnose issues by knowing exact version and installation type
    • Distinguishes between released versions and development builds
  2. Environment Configuration Insight

    • Provides valuable context about user's setup
    • Aids in debugging process without compromising security
  3. Security Compliance

    • Masks API keys and other sensitive information
    • Maintains user trust and follows security best practices
    • No sensitive data inadvertently exposed

📝 Files Changed

  • gpt_engineer/applications/cli/main.py (+385 lines)

    • Added 3 new functions
    • Enhanced output formatting
    • Added re import for pattern matching
  • tests/applications/cli/test_sysinfo.py (new file, +269 lines)

    • Comprehensive test coverage
    • Tests for all new functionality
    • Edge case handling

🔍 Breaking Changes

None. This PR only adds new functionality to the existing --sysinfo option without modifying any existing behavior.

✅ Checklist

  • Code follows the project's style guidelines (black, ruff)
  • Added comprehensive tests
  • All tests pass
  • Documentation (docstrings) added
  • No linting errors
  • Commit message follows conventional commits format
  • PR targets the main branch

🔗 Related Issues

This PR is labeled as a good first issue contribution.


Testing Instructions:

To test this PR locally:

# Install the package
poetry install
poetry shell

# Run the enhanced sysinfo
gpt-engineer --sysinfo

# Run the tests
pytest tests/applications/cli/test_sysinfo.py -v

Important

Enhances --sysinfo to include version and masked environment variables, with new functions and comprehensive tests added.

  • Behavior:
    • Enhances --sysinfo to include version and masked environment variables.
    • Adds get_gpt_engineer_version() to detect version and installation type.
    • Adds get_environment_variables() to capture and mask environment variables.
    • Updates get_system_info() to include new information.
  • Functions:
    • mask_sensitive_value() masks sensitive data in environment variables.
    • Improved output formatting in main.py for better readability.
  • Testing:
    • Adds test_sysinfo.py with comprehensive unit tests for new functions.
    • Tests cover version detection, environment variable masking, and system info structure.
  • Misc:
    • Adds re import in main.py for pattern matching.

This description was created by Ellipsis for 7e7b795. You can customize this summary. It will automatically update as commits are pushed.

…iables

- Add get_gpt_engineer_version() to detect version and installation type (released vs dev)
- Add get_environment_variables() to show relevant env vars with sensitive data masked
- Add mask_sensitive_value() to securely mask API keys and secrets
- Update get_system_info() to include version and environment information
- Improve sysinfo output formatting with better structure
- Add comprehensive unit tests for all new functionality

This enhancement helps with:
- Version tracking for better issue diagnosis
- Environment configuration insight while maintaining security
- Security compliance by masking sensitive information

Fixes: Issue requesting enhanced --sysinfo output
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to 7e7b795 in 2 minutes and 18 seconds. Click for details.
  • Reviewed 424 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. gpt_engineer/applications/cli/main.py:1
  • Draft comment:
    No license specification update found in this diff. Please include/update the LICENSE file as requested.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. gpt_engineer/applications/cli/main.py:311
  • Draft comment:
    Consider expanding the docstring to clarify how wildcard patterns (e.g. 'GPT_ENGINEER_*') are handled in get_environment_variables.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This is a documentation/docstring improvement suggestion. The rules state "Do NOT comment unless there is clearly a code change required" and "Do NOT make comments that are obvious or unimportant." The wildcard handling is already explained in an inline comment in the code itself (line 311), and the implementation is straightforward. The docstring already describes what the function does ("Get relevant environment variables with sensitive data masked"). Adding more detail about wildcard patterns to the docstring is a nice-to-have but not a required code change. This falls into the category of optional documentation improvements rather than necessary code fixes. The wildcard pattern handling might not be immediately obvious to users of this function just from reading the docstring. If someone is trying to understand what environment variables will be collected, knowing that wildcards are supported could be helpful information. However, the inline comment in the code already documents this. While the additional documentation could be helpful, the rules explicitly state not to comment unless there's a clear code change required. This is a documentation enhancement, not a bug fix or necessary change. The inline comment already documents the wildcard behavior for anyone reading the code. The function works correctly as-is. This comment should be deleted. It's a documentation improvement suggestion rather than a required code change. The wildcard behavior is already documented via inline comments in the code, and the function works correctly.
3. tests/applications/cli/test_sysinfo.py:17
  • Draft comment:
    Excellent and comprehensive tests for mask_sensitive_value covering long, short, empty, and sensitive cases.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. tests/applications/cli/test_sysinfo.py:120
  • Draft comment:
    Good use of patching to simulate package metadata in get_gpt_engineer_version tests; covers both released and development versions.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_VJyRErbKteWC7Z7z

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

try:
metadata = importlib.metadata.metadata("gpt-engineer")
# Check if installed in editable mode or from source
installer = metadata.get("Installer", "unknown")
Copy link

Choose a reason for hiding this comment

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

Unused variable installer in get_gpt_engineer_version; consider removing it if not needed.

Suggested change
installer = metadata.get("Installer", "unknown")

- Removed unused 'installer' variable that was retrieved but never used
- Updated tests to remove unnecessary metadata mocking
- Addresses code review feedback from Ellipsis bot
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