Skip to content

Improve robustness of env parsing and API error handling#28

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/optimize-code-quality
Draft

Improve robustness of env parsing and API error handling#28
Copilot wants to merge 2 commits into
mainfrom
copilot/optimize-code-quality

Conversation

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown

Summary

This PR introduces targeted code quality improvements to make the action more robust and fault-tolerant.

Changes

  • Hardened environment variable handling in main.py:
    • Added validated progress-bar length parsing with safe fallback
    • Clamped progress values to a valid 0-100 range
    • Reworked progress-bar assembly for clearer behavior
    • Added boolean parsing for INPUT_SHOW_EP_INFO to correctly handle values like false
  • Improved resilience in readme_level.py:
    • Added explicit handling for missing GitHub token
    • Added request exception handling for GitHub API calls
    • Added non-200 response handling
    • Added malformed API payload handling
    • Prevented crashes by handling missing user data in EP calculation
  • Extended tests:
    • Added tests for missing token and failed API response paths
    • Added test for EP calculation when user data is unavailable
    • Added test to ensure EP info is hidden when INPUT_SHOW_EP_INFO=false

Validation

  • python -m unittest
  • pylint $(git ls-files '*.py') ⚠️ (existing unrelated lint issue remains in graphql_query.py line length)
  • Parallel validation:
    • Code Review ✅ (no comments after fixes)
    • CodeQL Security Scan ✅ (0 alerts)

Copilot AI and others added 2 commits April 17, 2026 20:12
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