Skip to content

fix: handle non-numeric manifest icon keys in get_extension_icon to prevent ValueError crash#133

Closed
Copilot wants to merge 1 commit into
masterfrom
copilot/review-pr-and-submit-review
Closed

fix: handle non-numeric manifest icon keys in get_extension_icon to prevent ValueError crash#133
Copilot wants to merge 1 commit into
masterfrom
copilot/review-pr-and-submit-review

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

Fixes #131

Summary

get_extension_icon crashed with ValueError when a Chrome extension manifest's icons object contained non-numeric keys (e.g. "48x48", "icon") instead of pure integer strings like "48".

Root cause: max(manifest_icons.keys(), key=lambda x: int(x))int("48x48") raises ValueError.

Changes

  • Filter manifest icon keys to numeric-only using k.isdigit() before calling max()
  • Wrap the icon resolution block in if numeric_keys: so manifests with no numeric icon keys are skipped gracefully, falling through to the existing persisted-icon → placeholder fallback chain
  • Simplified key=lambda x: int(x)key=int

Review of PR #132

PR #132 (by @Th-Shivam) correctly identifies and targets the same bug. However, it has three issues this PR addresses:

Issue PR #132 This PR
No numeric keys Raises ValueError (caught by outer except Exception, logs misleading warning) Skips gracefully with if numeric_keys:
isinstance(k, str) guard Present (redundant — json.load always produces string keys) Removed
Lambda verbosity key=lambda x: int(x) key=int

Testing

  • CodeQL security scan: 0 alerts
  • No existing tests broken
  • Correct fallback behavior: extensions with non-numeric icon keys now silently fall through to the persisted icon or placeholder response

@sapnilbiswas sapnilbiswas deleted the copilot/review-pr-and-submit-review branch April 4, 2026 09:13
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.

handle non-numeric manifest icon keys in get_extension_icon to prevent ValueError crash

2 participants