Skip to content

Fix GitHub API authentication and add stats caching for resilient tracking#3

Merged
Lackadaisical-Security merged 5 commits intomainfrom
copilot/fix-real-time-stats-api
Jan 5, 2026
Merged

Fix GitHub API authentication and add stats caching for resilient tracking#3
Lackadaisical-Security merged 5 commits intomainfrom
copilot/fix-real-time-stats-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 5, 2026

The stats tracker was failing to collect GitHub metrics, leaving github: {} empty in all historical snapshots.

Changes

Authentication

  • Updated authorization header from deprecated token to Bearer format for GitHub App tokens (GITHUB_TOKEN)

Error handling

  • Parse actual error messages from API response bodies instead of generic HTTP codes
  • Differentiate between rate limiting, permission issues, and missing endpoints
  • Changed bare except: to except Exception: to avoid catching system exits

Stats caching

  • Preserve last successful GitHub stats when API calls fail
  • Add github_cached flag and visual indicators in output when using cached data

Workflow

  • Added metadata: read permission for repository metadata access

Example

When API calls fail, the tracker now preserves previous data:

# Before: API failure → empty stats
{"github": {}}

# After: API failure → cached stats with indicator
{
  "github": {"stars": 42, "forks": 5, ...},
  "github_cached": true
}

Error messages are now actionable:

⚠️  GitHub API error (403): API rate limit exceeded
💡 Set GITHUB_TOKEN env var for higher rate limits.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Lackadaisical-Security/Voynich-Script-Decoded
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py (http block)
    • Triggering command: `/usr/bin/python3 python3 -c
      import os
      import urllib.request
      import json

token = os.environ.get('GITHUB_TOKEN', None)
print(f'Token exists: {token is not None}')
print(f'Token length: {len(token) if token else 0}')

Try a simple API call

url = 'REDACTED` (http block)

  • Triggering command: `/usr/bin/python3 python3 -c
    import urllib.request
    import urllib.error
    import json

url = 'REDACTED'
headers = {'Accept': 'application/vnd.github.v3+json'}

try:
req = urllib.request.Request(url, headers=headers)` (http block)

  • https://api.github.com/repos/Lackadaisical-Security/Voynich-Script-Decoded/contributors
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py (http block)
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py queries -J-Xmx6101M _ _ _ _ _ _ _ _ conf�� get --global /usr/sbin/git credential.helpe/opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/tools/linux64/java/bin/java (http block)
  • https://api.github.com/repos/Lackadaisical-Security/Voynich-Script-Decoded/releases
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py (http block)
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py queries -J-Xmx6101M _ _ _ _ _ _ _ _ conf�� get --global /usr/sbin/git credential.helpe/opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/tools/linux64/java/bin/java (http block)
  • https://api.github.com/repos/Lackadaisical-Security/Voynich-Script-Decoded/traffic/clones
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py (http block)
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py queries -J-Xmx6101M _ _ _ _ _ _ _ _ conf�� get --global /usr/sbin/git credential.helpe/opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/tools/linux64/java/bin/java (http block)
  • https://api.github.com/repos/Lackadaisical-Security/Voynich-Script-Decoded/traffic/views
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py (http block)
    • Triggering command: /usr/bin/python3 python3 realtime_stats_tracker.py queries -J-Xmx6101M _ _ _ _ _ _ _ _ conf�� get --global /usr/sbin/git credential.helpe/opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/tools/linux64/java/bin/java (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Could you fix the real-time stats api to properly track?


💡 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.

Copilot AI and others added 4 commits January 5, 2026 14:30
Co-authored-by: Lackadaisical-Security <205846242+Lackadaisical-Security@users.noreply.github.com>
Co-authored-by: Lackadaisical-Security <205846242+Lackadaisical-Security@users.noreply.github.com>
Co-authored-by: Lackadaisical-Security <205846242+Lackadaisical-Security@users.noreply.github.com>
Co-authored-by: Lackadaisical-Security <205846242+Lackadaisical-Security@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix real-time stats API to properly track data Fix GitHub API authentication and add stats caching for resilient tracking Jan 5, 2026
Copy link
Copy Markdown
Owner

@Lackadaisical-Security Lackadaisical-Security left a comment

Choose a reason for hiding this comment

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

looks good hopefully goes through properly this round xd

@Lackadaisical-Security Lackadaisical-Security marked this pull request as ready for review January 5, 2026 14:41
@Lackadaisical-Security Lackadaisical-Security merged commit 175a907 into main Jan 5, 2026
@Lackadaisical-Security Lackadaisical-Security deleted the copilot/fix-real-time-stats-api branch January 5, 2026 14:44
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