fix(backend): allow non-numeric SKU IDs for legacy Windows products #10

Merged
starkSV merged 1 commit from feat/cf-worker-proxy into main 2026-05-18 12:46:28 +05:30
starkSV commented 2026-05-18 12:46:18 +05:30 (Migrated from github.com)

Replaced strconv.Atoi on sku_id with a permissive allowlist regex (alphanumeric, hyphens, underscores). Older products like Windows 8.1 (#48, #52) return non-integer SKU IDs from Microsoft API, causing the Get Download Links button to fail with 'sku_id must be a numeric value'.

Closes #9

Summary by CodeRabbit

  • Bug Fixes
    • SKU ID parameter now accepts non-numeric values while maintaining validation checks.
    • Enhanced error messages when invalid SKU IDs are submitted.

Review Change Stack

Replaced strconv.Atoi on sku_id with a permissive allowlist regex (alphanumeric, hyphens, underscores). Older products like Windows 8.1 (#48, #52) return non-integer SKU IDs from Microsoft API, causing the Get Download Links button to fail with 'sku_id must be a numeric value'. Closes #9 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * SKU ID parameter now accepts non-numeric values while maintaining validation checks. * Enhanced error messages when invalid SKU IDs are submitted. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/starkSV/windows-iso-downloader/pull/10?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2026-05-18 12:46:28 +05:30 (Migrated from github.com)

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d518034-ec2e-42b1-9056-55a7ddd309e7

📥 Commits

Reviewing files that changed from the base of the PR and between 2e2f9c5c48 and 106e2e2b31.

📒 Files selected for processing (1)
  • backend/main.go

📝 Walkthrough

Walkthrough

The PR replaces numeric-only validation of the sku_id parameter in the /proxy endpoint with a regex-based character allowlist. A compiled regex validSkuID is added to permit alphanumeric characters, underscores, and hyphens, allowing non-integer SKU IDs such as GUIDs and locale strings to pass validation.

Changes

SKU ID Validation

Layer / File(s) Summary
Regex-based SKU ID validation
backend/main.go
A compiled regex pattern validSkuID matching ^[a-zA-Z0-9_\-]+$ is introduced at the package level. The /proxy endpoint's sku_id validation replaces strconv.Atoi numeric parsing with a regex match check, returning 400 with "sku_id contains invalid characters" on mismatch.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • starkSV/windows-iso-downloader#2: Overlaps directly in the same /proxy endpoint's sku_id validation logic; PR #2 enforces numeric-only validation while this PR permits alphanumeric and special characters via regex.

Poem

🐰 A regex hops where numbers would fail,
Now GUIDs and strings tell their tale,
The SKU ID validation finds its way,
Old numeric walls crumble away!

Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cf-worker-proxy

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands and usage tips.

<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- This is an auto-generated comment: failure by coderabbit.ai --> > [!CAUTION] > ## Review failed > > The pull request is closed. <!-- end of auto-generated comment: failure by coderabbit.ai --> <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro Plus **Run ID**: `9d518034-ec2e-42b1-9056-55a7ddd309e7` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 2e2f9c5c48f48aefd0cbbd2b2b66fe8587aa4365 and 106e2e2b318187f58b9590b573329ebabc7e62ca. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `backend/main.go` </details> </details> --- <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The PR replaces numeric-only validation of the `sku_id` parameter in the `/proxy` endpoint with a regex-based character allowlist. A compiled regex `validSkuID` is added to permit alphanumeric characters, underscores, and hyphens, allowing non-integer SKU IDs such as GUIDs and locale strings to pass validation. ## Changes **SKU ID Validation** | Layer / File(s) | Summary | |---|---| | **Regex-based SKU ID validation** <br> `backend/main.go` | A compiled regex pattern `validSkuID` matching `^[a-zA-Z0-9_\-]+$` is introduced at the package level. The `/proxy` endpoint's `sku_id` validation replaces `strconv.Atoi` numeric parsing with a regex match check, returning `400` with `"sku_id contains invalid characters"` on mismatch. | ## Estimated code review effort 🎯 1 (Trivial) | ⏱️ ~3 minutes ## Possibly related PRs - [starkSV/windows-iso-downloader#2](https://github.com/starkSV/windows-iso-downloader/pull/2): Overlaps directly in the same `/proxy` endpoint's `sku_id` validation logic; PR `#2` enforces numeric-only validation while this PR permits alphanumeric and special characters via regex. ## Poem > 🐰 A regex hops where numbers would fail, > Now GUIDs and strings tell their tale, > The SKU ID validation finds its way, > Old numeric walls crumble away! ✨ </details> <!-- walkthrough_end --> <!-- finishing_touch_checkbox_start --> <details> <summary>✨ Finishing Touches</summary> <details> <summary>📝 Generate docstrings</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR - [ ] <!-- {"checkboxId": "3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch </details> <details> <summary>🧪 Generate unit tests (beta)</summary> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests - [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch `feat/cf-worker-proxy` </details> </details> <!-- finishing_touch_checkbox_end --> <!-- This is an auto-generated comment: all tool run failures by coderabbit.ai --> > [!WARNING] > There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. > > <details> > <summary>🔧 golangci-lint (2.12.2)</summary> > > level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" > > > > > </details> <!-- end of auto-generated comment: all tool run failures by coderabbit.ai --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub> <!-- tips_end --> <!-- internal state start --> <!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAZvAAeABQCaAwA1mS0AJRcaB4e+ADukBj4GGAYjpTwDJAAygDSAKqQAJIAIsg++HxeRKHyAOrwGLRJyLyK2GKIBgByjgKUXACMAAwGRTYAMlywuLjciBwA9CtE6rDYAhpMzCuIuM5heQBqK4ktbYmIYEiE1xgJaEoUK9zY8Svjk4jD9kcKCdTgY8vhsBQGCRIAIqBgGLBfCRqCsGD4wIkahEKGBOv55IAkwhgzlIuBhcIRXGY2gwoKOuGwy343DIBgAwhRkTR6NQuAAmMZ8gBsYDGAFYwCMABzQMYAdg4IyFiqlAC0jOVpAwKPBuOI0hwDDYSNwPKFpJBcLBoYzofgfADIWkJBoAIIEHSJa1YCRxeC0agtIj2MLYAD6/sglyt6B4lGYSEQkmhcQSiQ8SDJnNI/ktsGo6AYUL1yDi3HzmTYOtyCOcoRoFEQABpILBZOWyM30K1INhWpREExOYgNDAEMhaxhSOhaLRh38qtoPBCLV6yPwPK8eBQuj1IIESBoiBoW81Wu1IFKNCMopBOQyKFhUukWjRSHxCiUKlUd8w89CAFkch3RB7TJV0rFKFsvRyWBtxICR4HBRAPHkBg0FtegrWhAAiABxEgyXKJInnwF5IGmFowkQHDC31LACEgHwlyjTZ/0gSgdz4AByRBQwjehmEZMkhljStslyX1lxIbjRzgaFJ2nBgEgXFBEAcaEzAATg0cxLAAeWEURxCkH8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AGHLjhIwusDA+0yfQNuQc64W0WSwSOnA7xoFjs3Zw8g5AKGTu7NOXtM6nP1mOf2pYsBXJDjc9hdybbiMIkuW5yy5ZizCE3eO8g4Sd0Th8t2qdPYZyzoTAA3jhVFJBSi0BwhwQlHcSBhilFKEYtA+RdTGT4AUWkuo4SbDhAeVoyU4TzgFWghcaQl3ZftQEuB+kkDJWMrSHLIgSqlTK/aLyXA8tKLlCq3QLRI3IMkPY3B4BeCoaNSefBEnziQlgJeK817YA3reTCHNLp+lvtCURv8cofE0CKpZJAABC8s2QsFNIo2pPK0w4QAL5NgJUSklPKiVhlZS1MYDAxh0DFGKBgIquWwB5XyguPjhUcsOM4cVLRJUcDGUqWVrR5WVpGHKYtyrZA8rZEMuBj98DP0/iI4+7r/4WqYr+M6VYchgDSKhHgzgkxpWBnzfwYAQh/T4ZrPgA60gthIAmBY20kaLzoQwjiFAuLS3XL5LlDYsASOQFIyAMiEQaG9a7f1CLA3MGDf4UN5Lw0RsZtnA2PZLl4GDubMOtzrZRyhZww1GKYTyyRS3FFlLnYYqoF87F+ggA --> <!-- internal state end -->
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: shekhar/windows-iso-downloader#10
No description provided.