Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Fix failing camo length test

This PR fixes GitHub camo proxy URL length limit issues by reducing the max_url_length parameter from 3700 to 3550 characters and adding user-facing warnings when URLs exceed safe limits.

Changes Made

  • Reduced max_url_length: Changed default from 3700 to 3550 chars in svg_to_base64_data_uri() to account for badge URL overhead and provide 10% safety margin
  • Updated all call sites: Changed explicit calls to use 3550 instead of 3700
  • Improved docstring clarity: Explicitly labeled each overhead component (camo_overhead, hex_encoding, badge_url_overhead)
  • Docker-based CI testing: Tests now run inside the BadgeSort Docker container, ensuring consistent environment with all system dependencies (librsvg2-bin)
  • Console warnings: Added warnings when:
    • Badge URLs exceed GitHub's 8192 char camo limit
    • PNG fallback fails and oversized SVG is used despite exceeding limits

Technical Details

Calculation: (8192 - 76 camo_overhead) / 2 hex_encoding - ~109 badge_url_overhead = 3949, with 10% margin = 3550

The tighter limit ensures that badge URLs with embedded SVG data URIs stay under GitHub's camo proxy 8192 character limit, preventing "limit exceeded" errors for large icons like the Amazon AWS icon. When PNG fallback is available (via rsvg-convert), oversized SVGs are automatically converted to compact PNGs.

Testing

  • ✅ All 28 tests pass
  • ✅ PNG fallback works correctly when rsvg-convert is available
  • ✅ Warnings appear correctly when URLs exceed limits
  • ✅ CI tests run in Docker container with all dependencies

Fixes #108

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix failing camo length test</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


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

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Shields.io)

hilbert

Taichi Lang TikTok BadgeSort OBS Studio Tails USPS PagerDuty Harbor Etihad Airways Timescale WeGame Amazon TYPO3 Wattpad Quest Auchan Jekyll New Balance Starship Awesome Lists GNOME Angular Universal Lunacy Discord PlayStation 3 National Grid

hsv

Taichi Lang TikTok BadgeSort Jekyll Auchan Quest Wattpad TYPO3 Amazon WeGame Timescale Etihad Airways Harbor PagerDuty Angular Universal Lunacy GNOME PlayStation 3 National Grid Discord USPS Tails OBS Studio Starship Awesome Lists New Balance

step

Taichi Lang TikTok BadgeSort Jekyll Auchan Quest Wattpad Etihad Airways TYPO3 Amazon WeGame Timescale Harbor PagerDuty PlayStation 3 GNOME Lunacy Angular Universal National Grid USPS Tails Discord OBS Studio New Balance Starship Awesome Lists

step_invert

Taichi Lang TikTok BadgeSort Jekyll Auchan Quest Wattpad Etihad Airways TYPO3 Amazon WeGame Timescale Harbor PagerDuty PlayStation 3 GNOME Lunacy Angular Universal Discord Tails USPS National Grid OBS Studio Awesome Lists Starship New Balance

luminance

Taichi Lang TikTok BadgeSort National Grid OBS Studio PlayStation 3 Jekyll USPS New Balance Tails Auchan Starship Discord Quest Wattpad PagerDuty GNOME Lunacy Angular Universal Awesome Lists Etihad Airways Harbor TYPO3 Amazon WeGame Timescale

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Badgen.net)

hilbert

Taichi Lang TikTok BadgeSort OBS Studio Tails USPS PagerDuty Harbor Etihad Airways Timescale WeGame Amazon TYPO3 Wattpad Quest Auchan Jekyll New Balance Starship Awesome Lists GNOME Angular Universal Lunacy Discord PlayStation 3 National Grid

Co-authored-by: ChipWolf <3164166+ChipWolf@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing camo length test fix(icons): reduce max_url_length to 3550 to prevent camo proxy limit exceeded Nov 13, 2025
Copilot AI requested a review from ChipWolf November 13, 2025 15:43
@ChipWolf ChipWolf marked this pull request as ready for review November 13, 2025 15:44
Copilot AI review requested due to automatic review settings November 13, 2025 15:44
@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Shields.io)

hilbert

The North Face BadgeSort Wappalyzer Sailfish OS StubHub Max WEMO Exordo Overcast Monero CodeIgniter Namecheap Redmine Tekton Byju's Read the Docs Steemit Ring Disqus Amazon Prime Facebook Revolut Microsoft Exchange Iconify Aeroflot Caffeine

hsv

The North Face BadgeSort Max Namecheap CodeIgniter Monero Overcast Exordo WEMO Steemit Amazon Prime Ring Read the Docs Microsoft Exchange Iconify Disqus Sailfish OS Revolut Aeroflot StubHub Facebook Caffeine Wappalyzer Byju's Tekton Redmine

step

The North Face BadgeSort Max Namecheap CodeIgniter Monero Overcast Exordo WEMO Steemit StubHub Sailfish OS Aeroflot Iconify Revolut Microsoft Exchange Facebook Ring Amazon Prime Disqus Read the Docs Caffeine Wappalyzer Byju's Redmine Tekton

step_invert

The North Face BadgeSort Max Namecheap CodeIgniter Monero Overcast Exordo WEMO Steemit StubHub Sailfish OS Aeroflot Iconify Revolut Microsoft Exchange Facebook Ring Amazon Prime Disqus Read the Docs Wappalyzer Caffeine Byju's Tekton Redmine

luminance

The North Face BadgeSort Caffeine Wappalyzer StubHub Sailfish OS Aeroflot Redmine Byju's Max Iconify Namecheap Revolut Microsoft Exchange Facebook CodeIgniter Tekton Ring Amazon Prime Monero Disqus Overcast Read the Docs Steemit Exordo WEMO

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Badgen.net)

hilbert

The North Face BadgeSort Wappalyzer Sailfish OS StubHub Max WEMO Exordo Overcast Monero CodeIgniter Namecheap Redmine Tekton Byju's Read the Docs Steemit Ring Disqus Amazon Prime Facebook Revolut Microsoft Exchange Iconify Aeroflot Caffeine

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Shields.io)

hilbert

Octane Render mdBook BadgeSort Citrix Hootsuite BigBlueButton awesomeWM Celery Skynet Razer Gatling Xilinx Winmate Facebook Live Tinder PocketBase C Snowflake Barclays OpsLevel Zalo Microsoft Azure Simplenote Fortran Pimcore Anchor

hsv

Octane Render mdBook BadgeSort Tinder Facebook Live Gatling Razer Celery Skynet PocketBase Snowflake Barclays Microsoft Azure OpsLevel C Zalo Hootsuite awesomeWM Simplenote BigBlueButton Pimcore Anchor Citrix Fortran Winmate Xilinx

step

Octane Render mdBook BadgeSort Facebook Live Tinder Gatling Razer Celery Skynet Hootsuite Zalo awesomeWM Simplenote Microsoft Azure OpsLevel Barclays Snowflake C PocketBase Anchor Citrix BigBlueButton Pimcore Fortran Winmate Xilinx

step_invert

Octane Render mdBook BadgeSort Facebook Live Tinder Gatling Razer Skynet Celery Hootsuite Zalo awesomeWM Simplenote Microsoft Azure OpsLevel Barclays Snowflake C PocketBase Pimcore BigBlueButton Citrix Anchor Fortran Xilinx Winmate

luminance

Octane Render mdBook BadgeSort Anchor Hootsuite Citrix BigBlueButton Pimcore Winmate Xilinx Zalo awesomeWM Fortran Simplenote Microsoft Azure Facebook Live Celery OpsLevel Barclays Tinder Skynet Snowflake Gatling Razer C PocketBase

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Badgen.net)

hilbert

Octane Render mdBook BadgeSort Citrix Hootsuite BigBlueButton awesomeWM Celery Skynet Razer Gatling Xilinx Winmate Facebook Live Tinder PocketBase C Snowflake Barclays OpsLevel Zalo Microsoft Azure Simplenote Fortran Pimcore Anchor

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 fixes GitHub camo proxy URL length limit issues by reducing the max_url_length parameter from 3700 to 3550 characters. The tighter limit ensures that badge URLs with embedded SVG data URIs stay under GitHub's camo proxy 8192 character limit, preventing "limit exceeded" errors for large icons like the Amazon AWS icon.

Key Changes

  • Reduced default max_url_length from 3700 to 3550 in svg_to_base64_data_uri() function
  • Updated all explicit call sites to use 3550
  • Updated test assertions to reflect the new default value

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
badgesort/icons.py Updated function signature default parameter, docstring calculation, and two explicit call sites to use 3550 char limit
tests/test_camo_url_limits.py Updated test assertions and comments to verify the new 3550 char default value

Default 3550 chars ensures badge URLs stay under GitHub's camo proxy
8192 char limit (which hex-encodes URLs: 76 + url_len*2 <= 8192).
Calculation: safe_url = (8192 - 76) / 2 - overhead ≈ 3850, with 150 char margin = 3700
Calculation: safe_url = (8192 - 76) / 2 - overhead ≈ 3949, with 10% margin = 3550
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The calculation in the docstring could be clearer. Consider specifying what "overhead" refers to:

Calculation: safe_url = (8192 - 76) / 2 - ~109 badge_url_overhead3949, with 10% margin = 3550

or

Calculation: (8192 - 76 camo_overhead) / 2 hex_encoding - ~109 badge_url_overhead = 3949, with 10% margin = 3550

This makes it clear that the ~109 char overhead is the badge URL structure (domain, path, parameters) excluding the actual data URI payload.

Suggested change
Calculation: safe_url = (8192 - 76) / 2 - overhead 3949, with 10% margin = 3550
Calculation: (8192 - 76 camo_overhead) / 2 hex_encoding - ~109 badge_url_overhead = 3949, with 10% margin = 3550
(~109 char badge_url_overhead is the badge URL structure: domain, path, parameters, excluding the data URI payload)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the docstring for better clarity in commit fb06706. The calculation now explicitly labels each overhead component and explains what badge_url_overhead represents.

@ChipWolf
Copy link
Owner

The test failed in CI @copilot

FAILED tests/test_camo_url_limits.py::test_shields_embedded_svg_urls_under_camo_limit - AssertionError: Badge URL would exceed camo limit: 8552 > 8192
  URL: https://img.shields.io/badge/Amazon%20AWS-232F3E.svg?style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bx...
assert 8552 <= 8192

Co-authored-by: ChipWolf <3164166+ChipWolf@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

The test failed in CI @copilot

...

Fixed in commit fb06706. The CI failure was due to missing librsvg2-bin system dependency in the test job. Added a step to install it before running tests. The PNG fallback now works correctly in CI, converting large SVGs (like AWS) to compact PNGs that stay under the camo limit.

@ChipWolf
Copy link
Owner

@copilot Use the BadgeSort container in CI instead of this

Co-authored-by: ChipWolf <3164166+ChipWolf@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot Use the BadgeSort container in CI instead of this

Updated in commit 0ba8bc1. CI now builds and uses the BadgeSort Docker container to run tests, which includes all system dependencies (librsvg2-bin) by default. Also added console warnings when badge URLs exceed the GitHub camo limit or when PNG fallback fails.

Copilot AI changed the title fix(icons): reduce max_url_length to 3550 to prevent camo proxy limit exceeded fix(icons): reduce max_url_length to 3550 and add camo limit warnings Nov 13, 2025
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Default 3550 chars ensures badge URLs stay under GitHub's camo proxy
8192 char limit (which hex-encodes URLs: 76 + url_len*2 <= 8192).
Calculation: safe_url = (8192 - 76) / 2 - overhead ≈ 3850, with 150 char margin = 3700
Calculation: (8192 - 76 camo_overhead) / 2 hex_encoding - ~109 badge_url_overhead = 3949, with 10% margin = 3550
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The calculation description states "with 10% margin = 3550" but this is slightly unclear. The actual calculation would be: 3949 × 0.9 ≈ 3554, but the code uses 3550 (which is even more conservative). Consider clarifying the description to either:

  • "with ~10% margin (rounded down) = 3550" or
  • "with 399 char safety margin (≈10%) = 3550"

This would make it clearer that 3550 is a rounded-down value for safety.

Suggested change
Calculation: (8192 - 76 camo_overhead) / 2 hex_encoding - ~109 badge_url_overhead = 3949, with 10% margin = 3550
Calculation: (8192 - 76 camo_overhead) / 2 hex_encoding - ~109 badge_url_overhead = 3949, with ~10% margin (rounded down) = 3550

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Shields.io)

hilbert

ASUS BadgeSort Citrix Badgr Naver Groupon Swagger Liberapay smart Amazon OYO Moscow Metro ExpressVPN GitHub Sponsors Lerna RStudio Drooble Aircall tRPC ACM Elm Cisco StackShare Apache NetBeans IDE Jira Software Cloud 66

hsv

ASUS BadgeSort OYO Amazon smart Liberapay Swagger Groupon Naver Aircall Drooble tRPC Cisco ACM Elm StackShare RStudio Apache NetBeans IDE Cloud 66 Jira Software Badgr Citrix Lerna GitHub Sponsors Moscow Metro ExpressVPN

step

ASUS BadgeSort OYO Amazon smart Liberapay Groupon Swagger Aircall Naver Drooble Jira Software Apache NetBeans IDE ACM Cloud 66 StackShare Elm tRPC Cisco RStudio Badgr Citrix Lerna Moscow Metro ExpressVPN GitHub Sponsors

step_invert

ASUS BadgeSort OYO Amazon smart Liberapay Groupon Swagger Drooble Naver Aircall Jira Software Apache NetBeans IDE ACM Cloud 66 StackShare Elm tRPC Cisco RStudio Citrix Badgr Lerna GitHub Sponsors ExpressVPN Moscow Metro

luminance

ASUS BadgeSort Badgr Citrix Jira Software Moscow Metro Lerna OYO Apache NetBeans IDE ExpressVPN ACM Cloud 66 StackShare GitHub Sponsors Elm tRPC Cisco Aircall Groupon Naver Drooble RStudio Amazon smart Swagger Liberapay

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Badgen.net)

hilbert

ASUS BadgeSort Citrix Badgr Naver Groupon Swagger Liberapay smart Amazon OYO Moscow Metro ExpressVPN GitHub Sponsors Lerna RStudio Drooble Aircall tRPC ACM Elm Cisco StackShare Apache NetBeans IDE Jira Software Cloud 66

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Shields.io)

hilbert

BadgeSort Basecamp Nucleo Taco Bell AppSignal Greenhouse Instacart Buy Me A Coffee Amazon Fandango KinoPoisk NetBSD Swift Hurriyetemlak Microsoft Access Twilio Statamic CodeNewbie FeatHub Google Chrome Sourcegraph Bitcoin Cash OpenNebula Intel Deutsche Bank Ingress

hsv

BadgeSort FeatHub Hurriyetemlak Swift KinoPoisk NetBSD Fandango Amazon Buy Me A Coffee Instacart Greenhouse Bitcoin Cash Sourcegraph OpenNebula Nucleo Basecamp Intel AppSignal Google Chrome Deutsche Bank Ingress Taco Bell CodeNewbie Statamic Twilio Microsoft Access

step

BadgeSort Hurriyetemlak Swift KinoPoisk NetBSD Fandango FeatHub Amazon Buy Me A Coffee Instacart Greenhouse Bitcoin Cash Basecamp Nucleo AppSignal Intel OpenNebula Google Chrome Sourcegraph Taco Bell Deutsche Bank Ingress CodeNewbie Microsoft Access Twilio Statamic

step_invert

BadgeSort Hurriyetemlak Swift KinoPoisk NetBSD Fandango FeatHub Amazon Buy Me A Coffee Instacart Bitcoin Cash Greenhouse Basecamp Nucleo AppSignal Intel OpenNebula Google Chrome Sourcegraph Ingress Deutsche Bank Taco Bell CodeNewbie Statamic Twilio Microsoft Access

luminance

BadgeSort Taco Bell Deutsche Bank Basecamp Nucleo AppSignal CodeNewbie Microsoft Access Ingress Hurriyetemlak Intel Twilio Statamic OpenNebula Swift Google Chrome Greenhouse KinoPoisk NetBSD Instacart Fandango Bitcoin Cash FeatHub Sourcegraph Amazon Buy Me A Coffee

@github-actions
Copy link
Contributor

🏷️ Test Badge Generation (Badgen.net)

hilbert

BadgeSort Basecamp Nucleo Taco Bell AppSignal Greenhouse Instacart Buy Me A Coffee Amazon Fandango KinoPoisk NetBSD Swift Hurriyetemlak Microsoft Access Twilio Statamic CodeNewbie FeatHub Google Chrome Sourcegraph Bitcoin Cash OpenNebula Intel Deutsche Bank Ingress

@ChipWolf ChipWolf merged commit abc9f1a into main Nov 13, 2025
14 checks passed
@ChipWolf ChipWolf deleted the copilot/fix-camo-length-test branch November 13, 2025 16:33
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.

Fix failing camo length test

2 participants